0

I have a string in jQuery $(elm).parent().parent().html().

This string return :

    <input name="formpage" value="formulaire_test" type="hidden">
<input name="postOK" value="accuse.html" type="hidden">
<input name="postNOK" value="erreur.html" type="hidden">
<input name="mailFrom" value="-1,-1,-1" type="hidden">
<input name="mailToName" value="Nom" type="hidden">
<input name="mailTo" value="[email protected]" type="hidden">
<input name="mailSubject" value="Sujet" type="hidden">
<input value="name=mailText" type="hidden">
<div class="headerForm"><p>En tete</p></div>
<fieldset><legend>Nouveau</legend>
<div id="para0101" class="entry"><label for="id0101">sdf</label>
<input id="id0101" name="input0101" type="text"></div>
<div id="para0102" class="entry"><label for="id0102">sf</label>
<input id="id0102" name="input0102" type="text"></div>
<div id="para0103" class="entry"><label for="id0103">sfd</label>
<input id="id0103" name="input0103" type="text"></div></fieldset>
<div class="footer">pied form</div>
<div class="submit"><input value="annuler" type="reset">
<input value="envoyer" type="submit"></div>

How can i retrieve for example the value En tete in <div class="headerForm"> ??

Thanks !

0

5 Answers 5

1
$(".headerForm p",$(elm).parent().parent()).text();

this should do the trick

Sign up to request clarification or add additional context in comments.

Comments

1

You need jquery class selector to access required element and use text method of jquery to get its text.

requiredvalue = $('.headerForm').text();

2 Comments

I can't, i need to start with $(elm).parent().parent().html(), i can't choose directly $('.headerForm')
Thanks you have to tell more, with which element you want to refer it.
0

Try this: $(elm).parent().parent().find('.headerForm').text();

Comments

0
var xml = $('elm').parent().parent().html();
var xmlDoc = $.parseXML( xml );
var $xml = $( xmlDoc );
var $hdrFrm = $xml.find( "div.headerForm");

Comments

0

Try this way,

$(function () {
 var allHtml = $(elm).parent().parent().html();
 alert($(this).find('.headerForm p').html());
});

Comments

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.