例如,我有这个代码
<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 ' )有错的选择与不工作
那么你们有什么建议我应该做什么?
我有这个代码
<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)
但不起作用.那么你们有什么建议我应该做什么?