我搜索了jquery更改标签,虽然有很多答案他们不涉及我的问题。我想将标签更改为包含链接的其他内容。我似乎无法得到它的工作!我把JS放在代码的头部位置,但没有运气,甚至使用JSFiddle,请参阅下面的内容。我究竟做错了什么?通过JQuery更改表单标签上的标签
的jsfiddle https://jsfiddle.net/14tx86j5/
HTML
<input name="input_147.1" value="I agree to Veryappt’s Terms of Service" id="choice_3_147_1" type="checkbox">
<label for="choice_3_147_1" id="label_3_147_1">I agree to Companies Terms of Service</label>
jQuery的
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function($) {
$("#label_3_147_1 label").html('You also agree to our <a href="http://www.google.com/accounts/TOS" name="terms" target="_blank">Privacy Policy</a>, which describes how we process your information. <a href="https://support.google.com/accounts/answer/1733224?hl=en-GB" name="terms" target="_blank">Learn More</a> about why we ask for this information.');
});
</script>
你需要包括jquery自由https://code.jquery.com/jquery-1.12.3.min.js –
具有相同ID的两个元素总是会给你这些错误 –
除了现在发布的答案,我想知道你为什么要做这件事? 你不能只修改html? :P – twicejr