我需要$('.mk[value=x]')
工作,但不是$('.mk[value=1]')
。请有人帮助
<body>
<span class="mk" value="1">1</span>
<span class="mk" value="1">1</span>
<span class="mk" value="3">3</span>
<input id="update" type="button" value="1" />
</body>
<script type="text/javascript">
$('#update').click(function(){
var x = this.value //--> x =1
$('.mk[value=x]').each(function(key, value) { //--> NOT WORKING !
$('.mk[value=1]').each(function(key, value) { //--> WORKING !
$(this).replaceWith('<span class="mk" value="2">2</span>')
});
})
</script>