0

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.

3 Answers 3

1

Tried

$('[data-reveal-id="on_holiday"]').trigger('click');

or something of that sort?

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

What about:

$('[data-reveal-id="on_holiday"]').trigger('click');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.