How can I replace all input titles value in a form with input or textarea values using Jquery and 'each' ?

<form id="id001" action="" method="post">
    <fieldset id="F001">
    <legend>F001 : Consulter mes informations professionnelles</legend>
    <div id="msg"></div>
    <label for="EMPLOYEE_NUMBER">
        Matricule de l'agent:
    </label>
    <input name="EMPLOYEE_NUMBER" type="text" id="EMPLOYEE_NUMBER" value="ID999" readonly="readonly" />
    <br /> 
    <label for="LAST_NAME">
        Nom:
    </label>
    <input type="text" name="LAST_NAME" id="LAST_NAME" value="Test" title="" />
    <br /> 
    <label for="FIRST_NAME">
        Prénom:
    </label>
    <input type="text" name="FIRST_NAME" id="FIRST_NAME" value="Jack" title="" />
    <br /> 
    <br class="clear" />
    <label>
        &nbsp;
    </label>
        <input type="submit" value="Envoyer" />
        <input name="WF" type="hidden" id="WF" value="WF2" />
    </fieldset>
</form>

Thanks for your help...

Chris

有帮助吗?

解决方案

Try this

$("input, textarea").each(function(){
    $(this).attr("title", this.value);
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top