Jamie
Jamie

Reputation: 379

Change label on form label via JQuery

I searched for jquery change the labels although there were a lot of answers they didn't pertain to my question. I want to change the label to something else that includes links. I can't seem to get it to work!! I've put the JS in the head position of the code but had no luck and even used JSFiddle please see below. What am I doing wrong?

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>

Upvotes: 0

Views: 480

Answers (3)

Mohit Tiwari
Mohit Tiwari

Reputation: 165

You can use only id of label something like that:

$("#label_3_147_1").html('Put Your html here');

Upvotes: 0

Amar Singh
Amar Singh

Reputation: 5622

Works for me . You need to include JS Libraries

   $('#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

Upvotes: 0

Milind Anantwar
Milind Anantwar

Reputation: 82231

You have wrong Selector to target label element. The selector you have used looks for label element inside element with id label_3_147_1. You need to use:

$("#label_3_147_1")

Upvotes: 1

Related Questions