mardi 24 février 2015

Setting title attribute for a disabled input

``


I'm a newby, working with wordpress and jquery.


I have a plugin (it's well known and robust) called Contact Form 7.


It outputs a submit button like this: <input type="submit" value="Invia" class="wpcf7-form-control wpcf7-submit">.


Before accepting the privacy policy, the button is disabled and look like this: <input type="submit" value="Invia" class="wpcf7-form-control wpcf7-submit" disabled="disabled">.


Question is: how do I display via jquery a different title based on the disabled property? If the button is disabled, title should be "Please agree to our privacy policy to continue". If the button is not disabled, it should be "Send your request".


I tried different approaches, but none is working.


My guess would have been something like:





/* title for disabled submit */
if ($("input.wpcf7-submit").attr('disabled') == "disabled") {
$("input.wpcf7-submit").attr( "title", "Please agree to our privacy policy to continue" );
}
else {
$("input.wpcf7-submit").attr( "title", "Send your request" );
}



Thanks in advance for kind help.


Aucun commentaire:

Enregistrer un commentaire