小编Dan*_* Na的帖子

在$(this)选择器后选择特殊选择器

例如,我有这个代码

<script>

$(document).ready(function () {     
    $('span').each(function () {    

        $(this).html('<div></div>') ;    
        if ( $(this).attr('id') == 'W0' ) { $( this > div ?!!! ).text('0') }
        if ( $(this).attr('id') == 'W1' ) { $( this > div ?!!! ).text('1') }
        if ( $(this).attr('id') == 'W2' ) { $( this > div ?!!! ).text('2') }

    });     
});

</script>

<span id="W0"></span>
<span id="W1"></span>
<span id="W2"></span>
Run Code Online (Sandbox Code Playgroud)

$( this > div )还是$( this ' > div ' )有错的选择与不工作

那么你们有什么建议我应该做什么?

html javascript jquery jquery-selectors

3
推荐指数
2
解决办法
119
查看次数

在svg路径上设置href属性

我有这个代码

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="20 0 970 960" enable-background="new 20 0 970 960" xml:space="preserve">
    <g class="border">
        <path class="City1" d="......" /> 
        <path class="City2" d="......" />
        <path class="City3" d="......" />              
        <path class="City4" d="......" />           
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

我需要<a href="#..."></a>在每个补丁上设置一个href属性.像这样

<a href="#...">
    <path class="City1" d="......" />
</a> 
<a href="#...">
    <path class="City2" d="......" />
</a>
<a href="#...">
    <path class="City3" d="......" />
</a>             
<a href="#...">
    <path class="City4" d="......" />
</a>
Run Code Online (Sandbox Code Playgroud)

但不起作用.那么你们有什么建议我应该做什么?

html svg

2
推荐指数
1
解决办法
2233
查看次数

标签 统计

html ×2

javascript ×1

jquery ×1

jquery-selectors ×1

svg ×1