Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › compatibility problems with javascript
This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 4 years, 10 months ago.
- AuthorPosts
- July 17, 2018 at 11:52 am #18680
I want to make a customization with jquery.
I have already customized other parts of my site with jquery and everything is going well.
I want to move the mouse over any of the search results and I would like something like this:
see attached fig.1.I know that the support does not include customizations.
however, I think there is a conflict when I try to add a simple event like the example:$(“.overlap”).mouseover(function(){
$(this).css(“background-color”,”red”);
});
This code is included in a js file duly registered in wordpress.
I do not know what may be happening.
Can you help me?
Thank youAttachments:
You must be logged in to view attached files.July 17, 2018 at 2:27 pm #18685Hi,
The issue is, that the ajax results are considered as dynamically generated/inserted elements on the DOM node tree. Your code however will only work with items, that are present at the page load. You need a dynamic event binding function.
To correctly attach a handler, you need to use the jQuery.fn.on(..) function. In your case, something like this:
If I may recommend an alternative solution. Changing colors is much simpler by using custom CSS. In your case:
.asp_r .overlap:hover { background-color: red; }
That is much simpler in my opinion 🙂
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.