我需要通过跨度中的 jQuery访问某物的标题。
<span class="checkbox">
<input name="item_add" value="1234" type="checkbox"> The Title of Something, </span>
谁能帮帮我吗 ?
您不能有来自输入元素的任何内部文本或内部 html。它们是空元素。他们没有结束标签。您必须创建一个跨度才能到达输入标签下方所需的文本。
<span class="checkbox">
<input name="item_add" value="1234" type="checkbox">
<span id="textSpan">
The title of something
</span>
</span>
<script>
$(document).ready(function{
var text = $('#textSpan').text();
//you have the inner text now.You can change it like this.
$('#textSpan').text()= "new text";
});
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句