【发布时间】:2015-05-29 06:59:36
【问题描述】:
例如我有这个代码
<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>
但 $( this > div ) 或 $( this ' > div ' ) 选择器错误且不起作用
那么你们建议我应该怎么做?
【问题讨论】:
标签: javascript jquery html jquery-selectors