Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 753639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:55:15+00:00 2026-05-14T14:55:15+00:00

it’s i first time i’m asking here. Sorry if the answer is available already.

  • 0

it’s i first time i’m asking here. Sorry if the answer is available already.

I have a very small jQuery script that canges the paramether for onclick attr on a DIV.

IT works like as right and left arrows for some content in the middle.

Basically i set the onclick="foo(1)" then when get clicked sld change the value 1 to 2, and keep changing everytime i click.

on jQuery functio i’m using:

$("#v_arrow_r").attr('onclick','').unbind().click(newclick_next);

it works like a charm on FF and Chrome, but does not work on IE !!!! Argh…

here the the code:

if (start == 24) {
 var a = 0;
 var b = 0;
} else {
 var a = start-6;
 var b = start+6;
}

next = "home_featured_videos(" + b + ");"; 
newclick_next = eval("(function(){"+next+"});");

prev = "home_featured_videos(" + a + ");";
newclick_prev = eval("(function(){"+prev+"});");

$('#video-module').css('background','');
$('#video-module').html(response);

$("#v_arrow_l").attr('onclick','').unbind().click(newclick_prev);
$("#v_arrow_r").attr('onclick','').unbind().click(newclick_next);

The html:

<div id="videos-home">
  <div class="arrow-l" id="v_arrow_l" onclick="home_featured_videos(0);"></div>
  <div class="content" id="video-module">
   //CONTENT
  </div>
  <div class="arrow-r" id="v_arrow_r" onclick="home_featured_videos(6);"></div>
  <div class="clear_b"></div>
</div>

So like i said.. i define the attr onclick when page open. It work well on IE. but when i click the arrow and call the function the oncli is set to null and i add the function to .click. IE stop working. the click is dead.

If anybody have idea why this is happening.

Thanx in advance.
Kind Regards

Varois

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:55:15+00:00Added an answer on May 14, 2026 at 2:55 pm
    $("#v_arrow_r").attr('onclick','').
    

    Don’t use attr to set event handler attributes. It doesn’t work in IE and it’s ugly and inefficient everywhere. If you’re using jQuery, use the methods jQuery gives you for event binding, such as click().

    Inline event handler attributes are an old-school hack you should generally avoid anyway.

    next = "home_featured_videos(" + b + ");"; 
    newclick_next = eval("(function(){"+next+"});");
    

    You should almost never use eval, and you certainly don’t want to assign a new handler function every time there’s a click. Store the current state in a variable and read it from the handler. For example:

    <div id="videos-home">
        <div class="arrow-l" id="v_arrow_l""></div>
        <div class="content" id="video-module">
            //CONTENT
        </div>
        <div class="arrow-r" id="v_arrow_r"></div>
        <div class="clear_b"></div>
    </div>
    <script type="text/javascript">
    
        var pagei= 0; // initial page number
        var pagen= 4; // 4 pages (of 6 items each)
    
        $('#v_arrow_l').click(function() {
            turnpage(-1);
        });
        $('#v_arrow_r').click(function() {
            turnpage(1);
        });
    
        function turnpage(d) {
            pagei= (pagei+pagen+d)%pagen;
            $('#video-module').css('background','');
            $('#video-module').html('Page '+pagei); // or load() some AJAX or whatever
        }
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.