#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,659
    Rep Power
    171

    Onclick does not work but onmouseover works!


    Hi;

    This is about IE. In Firefox its all good.

    I am calling the same function with onclick ( so it changes the INNER HTML) and it does not work. When I call the same funciton with mouseover it works fine! What am I doing wrong?

    Thank you

    Does NOT work:
    Code:
    <div class="option" onclick="edit_value('This Opption 2');">
        	This Option 2
    </div>
    Does work:
    Code:
    <div class="option" onmouseover="edit_value('This Opption 2');">
        	This Option 2
    </div>
    Code:
    function edit_value(argument) 
    	{
    		$(".behnam").html(argument);  
    	}
    Last edited by zxcvbnm; June 24th, 2013 at 01:44 AM.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Location
    Jakarta, Indonesia.
    Posts
    203
    Rep Power
    31
    THis one following is working fine on my desktop IE.8.
    Are you testing thi on IE for mobiles
    PHP Code:
    <html>
    <
    head>
        <
    title>test</title>
        <
    script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
        <script type="text/javascript">
    function edit_value(argument) 
        {
            $(".behnam").html(argument);  
        }
        </script>
    </head>
    <body>
    <div class="option" onclick="edit_value('This Opption 2');">
            This Option 2
    </div>
        <div class="behnam"></div>
    </body>
    </html> 
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,659
    Rep Power
    171
    Originally Posted by hdewantara
    THis one following is working fine on my desktop IE.8.
    Hi;

    Does it change the value of inner html?
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Location
    Jakarta, Indonesia.
    Posts
    203
    Rep Power
    31
    Yes, the div.benham in IE did SHOW the 'This Opption 2' as a new text element. And when I checked it with IE's Developer Tools (F12), the DOM for this div also contains that text element.

    Could you pass an url of your page here?
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,659
    Rep Power
    171
    Originally Posted by hdewantara
    Yes, the div.benham in IE did SHOW the 'This Opption 2' as a new text element. And when I checked it with IE's Developer Tools (F12), the DOM for this div also contains that text element.

    Could you pass an url of your page here?
    Hi;
    It's here
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Location
    Jakarta, Indonesia.
    Posts
    203
    Rep Power
    31
    PHP Code:
    <script>
    $(
    document).ready(function() {

        var 
    open_stat false;
        
        
    //install handler on HTML
        
    $('html')
            .
    click(function(){
                $(
    '.behnam').removeClass('focus');
                $(
    '.options').css('display','none');
            });
        
        
    //install handlers on .BEHNAM
        
    $('.behnam')
            .
    hover(
                function(){ 
    //mouseenter
                    
    $(this).css('border''1px solid #8c8c8c');
                },
                function(){ 
    //mouseout
                    
    $(this).css('border''1px solid #cccccc');
                }
            )
            .
    blur(function(){
                $(
    '.behnam').removeClass('focus');
                
    //$('.options').css('display','none'); 
            
    })
            .
    click(function(ev){
                
    ev.stopPropagation();
                if (
    open_stat==true){
                    
    open_stat=false;
                    $(
    '.behnam').removeClass('focus'); 
                    $(
    '.options').css('display','none'); 
                }
                else{
                    
    open_stat=true;
                    $(
    '.behnam').addClass('focus'); 
                    $(
    '.options').css('display','block'); 
                }
            });
        
        
    //install handlers on .OPTION
        
    $('.option')
            .
    hover(
                function() { 
    //mouseenter
                    
    $(this).css({
                        
    'background-color''#0084C7',
                        
    'color''White'
                    
    })
                },
                function() { 
    //mouseout
                    
    $(this).css({
                        
    'background-color''White',
                        
    'color''Black'
                    
    });
                }
            );

    });

    function 
    edit_value(argument) {
        $(
    ".behnam").html(argument); 
    }
    </script> 
    I hav to rewrite your script to identify the cause of IE being ignorant, and maybe its the blur() for .benham.

    Everytime you click one of the option, .benham looses focus and .options (and all its children) are gone.

    So IE thinks that you've clicked on... nothing, and edit_value() doesn't get executed
    Last edited by hdewantara; June 25th, 2013 at 02:18 PM.

IMN logo majestic logo threadwatch logo seochat tools logo