美好的一天。獲取元素ID號並使用jQuery追加它
我正在嘗試使用jQuery從鏈接ID中提取序列號並使用jQuery對其進行追加。
<a class="links" id="link_*serial number goes here*" href="google.com"> Google.com </a>
和腳本是這樣的
$('.links').append('<div>
<label> Check this box to remove this link:</label>
<input type="checkbox" id="delete_link_id'.parseInt($(this).attr("id"));.'></input></div>');
有什麼建議?
嗯,**不要**追加一個標籤和錨內輸入!你確定你不想'.after()'而不是'.append()'? –
這似乎是反覆的建議,請問爲什麼在這種情況下使用append這麼糟糕? – shultz
正如我在我的回答中解釋的,在'a'標籤內放置'label' /'input'在所有當前版本的html中都是無效的。 –