Reputation:
My current code that i use is this:
<script type="text/javascript">
$(document).ready(function(){
$('#on_holiday').trigger('click');
});
</script>
How ever, this only works when the 'ID' is 'on_holiday' within the input form. I need this to work when I have another element within the form - The current 'ID' is:
<a href="#" data-reveal-id="on_holiday" class="side_link">Test</a>
My problem is when ever I add the element 'ID' to this link, it messes up the data-reveal-id and its cause. I need some sort of jQuery code that can click this link without the need to put the 'ID' field in.
Many thanks in advance.
Upvotes: 0
Views: 11584
Reputation: 705
What about:
$('[data-reveal-id="on_holiday"]').trigger('click');
Upvotes: 0
Reputation: 7947
Well you have a number of options. Take a look at the jQuery selectors page.
http://api.jquery.com/category/selectors/
$("a").click(); //by tag.
$("a[href='#']").click(); //by tag with href property
$(".side_link").click(); //by class
$("div#someId a.side_link").click(); // This would work if the link was a child of a div with Id = someId
Upvotes: 0
Reputation: 78520
Tried
$('[data-reveal-id="on_holiday"]').trigger('click');
or something of that sort?
Upvotes: 1