Hello guys,
I am writing a Greasmonkey script and I need little help here. So I have this code:

$(document).ready (get);

function get ()
{
                var elems =$( "a[id*='myId.']" );
                                    if (elems.length>0) {
                                     $("a[id*='myId.']").trigger("click");
                                    }
                       }

the point is that there are a lot of a tags with id myId.N where N is different number. But that click just doesn't work. Any ideas?

Regards,
Fr3aK

Just use same class name for all a tag which have myId.N

But I want the a tags to be clicked and the trigger doesnt work. This is the problem. I think...

simple , try this

$('a').click(function(){
    var id = jQuery(this).attr("id");
    //now you have id of clicked tag.

    alert($('#' + id).length());

});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.