从班级获取ID的价值 [英] Getting value of ID from class
本文介绍了从班级获取ID的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Google标签管理器从类中获取ID的值?
< html>
< body>
< textarea id ='5'class ='cp _check'> sometexthere< / textarea>
< / body>
< html>
使用JQuery可以这样做:
$(。cp._check)。attr(id)
解决方案
转到变量,选择new,键入DOM。选择CSS选择器。然后,您可以使用类似于jQuery的选择器:
$ b
尽管可能会有多个匹配的选择符,GTM只会检索第一个匹配的值。
How is it possible to get the value of ID from class using google tag manager?
<html>
<body>
<textarea id='5' class='cp _check'>sometexthere</textarea>
</body>
<html>
Using JQuery it is possible with this:
$(".cp._check").attr("id")
解决方案
Go to variables, select new, type DOM. Select CSS selector. You can then use selectors similarly to jQuery:
Even though there might be multiple matches for your selector GTM retrieves the value for the first occurence only.
这篇关于从班级获取ID的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文