Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将引导的$this属性/属性用作参数_Javascript_Twitter Bootstrap_Javascript Objects - Fatal编程技术网

Javascript 如何将引导的$this属性/属性用作参数

Javascript 如何将引导的$this属性/属性用作参数,javascript,twitter-bootstrap,javascript-objects,Javascript,Twitter Bootstrap,Javascript Objects,如何为twitter引导参数值获取popover的this属性,比如我需要获取列表项属性,即引导popover标题中要使用的数据boothtype?但数据标题还不够 HTML <li class="booth" data-boothnumber="46" data-boothtype="prime" style="left: 240px; top: 30px;">46</li> 附言: 回调函数是来自的测试单元 编辑 ok这里的范围缩小了:使用JQuery,您可以执行以

如何为twitter引导参数值获取popover的this属性,比如我需要获取列表项属性,即引导popover标题中要使用的数据boothtype?但数据标题还不够

HTML

<li class="booth" data-boothnumber="46" data-boothtype="prime" style="left: 240px; top: 30px;">46</li>
附言: 回调函数是来自的测试单元

编辑
ok这里的范围缩小了:

使用JQuery,您可以执行以下操作:

$('.booth').data('boothnumber')
有关需要执行的.data()api的信息,请参见

$('.booth').each(function(i, v){
    var $el = $(v);
    $el.popover({
        title: 'test' + $el.data('boothnumber'), 
        content: "test", 
        placement: "right"
    });
});

演示:

此.data boothtype
甚至不是有效的JavaScript代码。首先获得最基本的东西是很重要的…哦,是的,无论如何,谢谢你,只是想调用对象的属性。。。也许除了这一点,我还遗漏了很多基础知识……不过,这个问题可能会让人产生误解,对此我深表歉意,谢谢你。我只是想把当前($this)数据用在bootstrap popover标题中。。。在这里让我帮你帮我:)我从来没有想过递归调用dom和每个给定的属性w/c都可以直接访问是一个好主意,不管怎样,感谢这一点,这里有一个向上投票:)在这种情况下,这是唯一的方法,因为标题必须动态查找
$('.booth').data('boothnumber')
$('.booth').each(function(i, v){
    var $el = $(v);
    $el.popover({
        title: 'test' + $el.data('boothnumber'), 
        content: "test", 
        placement: "right"
    });
});