I figured enough jQuery to select this chunk out of a huge HTML document. I want to select the value of subject, body, and date_or_offset. (these are name attributes as shown below). How do I go about this. Assuming this print is from alert($(this).html()) inside a call back function.
<p><label for="first">Subject</label> <br>
<input class="input" name="subject" type="text">
</p>
<p><label for="textarea">Body </label> <br>
<textarea class="textarea" name="body" id="textarea" rows="5" cols="30"></textarea>
</p>
<p><label for="first">Date <span>(xx/xx/xxxx) or Offset</span></label> <br>
<input class="input" name="date_or_offset" id="first" type="text">
</p>
You can get it via
.find()and.val(), like this:Since IDs are unique, the last 2 can be selected via a
#IDselector directly, the first we find byname="subject"using an attribute-equals selector. If the IDs aren’t unique (and they should be, fix it if that’s the case) you can use a simular[name=xx]selector for the others, just usetextareainstead ofinputfor thebodyelement.