简体   繁体   English

如何在JavaScript中使用jQuery

[英]how to use jquery with in javascript

function() {
     jQuery("body").on("click","#hoverView",function() {        
       var a = jQuery(this).attr("pname")
       var b = jQuery(this). attr("onclick")
       var c = b.split("/");
       var d = c[c.length-1].replace('"','');
       var z = a +   "|"   +   d; 
     })return z
}

with the code given above i am trying to pass this value via google tag manger. 与上面给出的代码,我试图通过谷歌标签管理器传递这个值。 but i couldn't do it. 但我做不到。 please help me how to return this value.can we return click event value? 请帮助我如何返回该值。能否返回点击事件值?

Try this: 尝试这个:

function() {
    var z;
    $("document").on("click","#hoverView", function(){        
        var a = $(this).attr("pname");
        var b = $(this). attr("onclick");
        var c = b.split("/");
        var d = c[c.length-1].replace('"','');
        z = a +   "|"   +   d; 
    });
    return z;
}

Or, simply Add an onlick event Lister to the hoverview, onclick="functionName" As a tag to the element. 或者,只需将onlick事件列表器添加到悬停视图中,将onclick =“ functionName”作为元素的标记。

you can use like that 你可以这样使用

var temp = ""; var temp =“”;

$(document).ready(funciton(){ $(文件)。就绪(功能可按(){

 $("body").on("click","#hoverView",function()
  {        
     var a = jQuery(this).attr("pname")
     var b = jQuery(this). attr("onclick")
     var c = b.split("/");``
     var d = c[c.length-1].replace('"','');
     var z = a +   "|"   +   d; 
     temp = z;
 }); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM