Search code examples
jqueryformstextinput

JQuery - How to only target the title tags of text input elements?


At the moment I am using two plug-ins which both look at title tags so they are clashing with each other.

The one I have started using is for tooltips on text input fields that is initialised in the following way:

$("[title]").mbTooltip

What I would like to do is either only target the titles of text boxes or even those with of class text.

I tried this myself but couldn't get it to work and I haven't found anything on the web about how to do it either :(


Solution

  • You can try this:

    $(".text[title][title!=]")
    

    This will select elements with the text class that have a non-empty title attribute

    working example: http://jsfiddle.net/hunter/GdU7E/


    Or this:

    $("input:textbox[title][title!=]")
    

    Which will select all textbox input elements with a non-empty title attribute

    working example: http://jsfiddle.net/hunter/GdU7E/1/