0

I am trying to change the innerHTML of a label. I do not have access to the form so cannot edit the HTML. The only identifier that the label has is the "for" attribute.

Here is the structure of the input and label:

    <div class="fullWidthContent" id="questionCheckboxDiv" style="display: block;">
      <div class="questionLabel"></div>
      <div class="questionCheckboxFormFieldContainer">
        <span class="questionCheckbox">
          <input type="checkbox" onclick="checkdep(this);" onblur="validatefield(this);" checked="" value="Y" name="Question Checkbox" id="Question_Checkbox">
          <label for="Question_Checkbox">I'd like to change this label text!</label>
        </span>
      </div>
    </div>
1
  • and what is the problem? Commented Jul 16, 2014 at 12:08

1 Answer 1

2

You can use the attributes selector as for is just an attribute

$('label[for="Question_Checkbox"]').text('something')
Sign up to request clarification or add additional context in comments.

1 Comment

use .html() to change the innerHTML

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.