2016-08-08 3 views
0

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> 
+0

jquery liberaryを含める必要がありますhttps://code.jquery.com/jquery-1.12.3.min.js –

+0

同じIDを持つ2つの要素は、常にこれらのエラーを表示します –

+0

今投稿されている回答は別としてなぜあなたはこのことをやるのだろう? htmlを変更できませんか? :P – twicejr

答えて

1

あなたは、label要素をターゲットに間違ったセレクタを持っています。使用したセレクタは、idがlabel_3_147_1のラベル要素を検索します。あなたは使用する必要があります:

$("#label_3_147_1") 
0

私のために働く。 あなたはJSライブラリあなたはそのようなラベル何かのIDのみ使用することができます

$('#label_3_147_1').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.'); 

    }); 

Fiddle

0

含める必要があります。

$( "#のlabel_3_147_1")をHTML( 'あなたを置きますここにhtml ');

関連する問題