0

Here I am trying to set title dynamically to the native drop-down to show tool-tip, but when I am trying to set title on hover I can't select any value from drop down options. That drop down is getting closed.

$(container).on("hover","select", function (e) {
  $(this).attr("title",$(this).val());
});

What can be the reason for this?

4
  • please add a fiddle , also what is container ? Commented Dec 11, 2013 at 10:40
  • container is just a parent <div> I am rendering DOM by soy template so I have to do event delegation. Commented Dec 11, 2013 at 10:47
  • See this stackoverflow.com/questions/4772287/… Commented Dec 11, 2013 at 11:29
  • Sorry I forgot to mention this issue was occuring only in IE8. Commented Dec 11, 2013 at 13:57

2 Answers 2

1

The $.on("hover") event was removed in jQuery 1.9.

You could try this:

$(container).hover(
  function() {
    $(this).attr("title", $(this).val());
  }, function() {
    $(this).attr("title", "");
  }
);
Sign up to request clarification or add additional context in comments.

5 Comments

Your suggestion might work, but I was talking about your statement that $.on() is incorrect.
i mean use "hover" in such way $(container).on('hover', function(){}) It isn't work
Have you even tried? It does work, hence your statement is false.
Appologies. It seems you are partly correct. The "hover" event has been deprecated in jQuery since 1.9. Older versions work: jsfiddle.net/zz9kT/2 Ref: stackoverflow.com/questions/14830064/…
In our project we are using jquery 1.8.3 so hover works like that. But my question was why I was unable to select value from drop down only when I am using title attribute.
0

Try the mouseenter event - not sure whether some other script is closing the dropdown

$('body').on("mouseenter", "select", function (e) {
    $(this).attr("title", this.value);
});

Demo: Fiddle

2 Comments

I know it is working with mouse enter.This problem is occuring mouse leave and hover is combination of two it is not working. But I just want to know the reason why only "title" attribute causing this problem.
@user3090654 which is the hover event... can you edit the fiddle to recreate the problem

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.