ontouchstart and ontouchend in jquery?

I am currently using the following for every element I want to change the class of on touch:

ontouchstart="$(this).addClass('select');" ontouchend="$(this).removeClass('select');"

I was wondering if there is something like this?:

$("#element").touchstart(function(){
    $(this).addClass('select');
},
function(){
   $(this).removeClass('select');
});

That I would be able to list all the elements that I want to have this property. I have tried so many things and cant get it to work.

Answers


I ended up just using this:

$('#nav li').bind('touchstart', function(){
    $(this).addClass('select');
}).bind('touchend', function(){
    $(this).removeClass('select');
});

Need Your Help

iOS - EXC bad access, previously worked on iOS 4

iphone ios uitableview exc-bad-access

Unless I'm out of my mind, this was working properly on iOS4. I updated to iOS5, and now it's throwing this bad access error on [indexPath section]. It's on a UITableView:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.