How to add id/class or name to this script

4 replies
I want to call UnPopIt when a user clicks on the button whose id is
'joinlist' but I can't figure out how to modify the script correctly. The button is named 'submt' class='wp-button'.
____________________________________________
<script type="text/javascript">
function PopIt() {
$("a#trigger").trigger('click');
window.onbeforeunload = UnPopIt;
return "Would you like to join our mailing list for other offers?";
}
function UnPopIt() { /* nothing to return */ }

$(document).ready(function() {
window.onbeforeunload = PopIt;

$("a#trigger").fancybox({
'hideOnContentClick': false,
'showCloseButton': false
});

$("a[id!=trigger]").click(function(){ window.onbeforeunload =
UnPopIt; });
});
</script>
#add #id or class #script
  • Profile picture of the author webpeon
    use the onclick html element to trigger the function

    eg.

    <input type="button" value="Submit" class="wp-button" onclick="UnPopIt()" />
    Signature
    Web 2 Mobile
    The Future of The Web
    {{ DiscussionBoard.errors[6374920].message }}
  • Profile picture of the author CoursesWeb
    Hi,
    You can also use this jQuery code:
    Code:
    $('#joinlist').click(function(){ UnPopIt(); });
    {{ DiscussionBoard.errors[6396828].message }}
  • Profile picture of the author eluminousdev
    Yes, code given by the "coursesweb" will do the job for you.
    {{ DiscussionBoard.errors[6433451].message }}
    • Profile picture of the author Dinamicore
      Hello: this is an old thread but it is exactly the code I am using now.

      I want to style, either with css or inline style, the text inside the return of the function:

      "Would you like to join our mailing list for other offers?";

      Not any documentation or even a reference to this.

      Any help, much appreciated
      {{ DiscussionBoard.errors[9316778].message }}

Trending Topics