我想從其他頁面定位鏈接中移除div id類。如何從其他頁面添加div類?
firstPage.html
<div class="question show" id="a1">
Sample 1
</div>
<div class="question" id="a2">
Sample 2
</div>
list.html
$(function() {
$("a").click(function() {
$("#a2").addClass('question show');
});
});
</script>
</head>
<body>
<a href="firstPage.html#a1">Link 1</a>
<a href="firstPage.html#a2">Link 2</a>
</body>
我想補充addClass('question show')
類被點擊的DIV ID。
我想在這裏與Link1
爲id=a1
But I'm failed to set class ('question show') help me to correct my code
請檢查代碼在這裏 http://plnkr.co/edit/fzdfjdrRbcWmir5wHcJW?p=preview
更好的是你可以在[Plunker](http://plnkr.co) –
中展示你的代碼a1已經有了這個類,試試'$(「#a2」).addClass('show');'那是你是什麼意思??令人困惑的措辭..也可以類有2個字? –
@Jit,是的,'class'可以包含多個以空格分隔的類名稱 – freefaller