Link to home
Start Free TrialLog in
Avatar of Bobby X
Bobby XFlag for United States of America

asked on

Need help with jQuery elements filtering

Hi,

How do I filter the list of elements below so that $('button,a') will use css('cursor','pointer') and $('input,select,textarea') will use css('cursor','text')? I'd like to be able to chain everything together so that only "button" and "a" will use the cursor "pointer" and the others will use cursor "text".

var myElemList = $('button,input,select,textarea,a').filter(function(){
                                    return $(this).hasClass("some-class);
                              }).prop('disabled',false)
                                    .css('cursor','pointer')
                                    .click(function(){return true;});

Many thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you're going about this wrong, you really should be using CSS for what you want and not JQuery.

a,button{
  cursor:pointer;
}

input,select,textarea{
  cursor:text;
}

Open in new window


jquery is better suited for interactions, when it comes to styling you should stick to css, even if you want to change the way things look use jquery or javascript to add classes to html elements, but specify the styles in CSS