www.webdeveloper.com
Results 1 to 2 of 2

Thread: jQuery focus() handler not triggering.

  1. #1
    Join Date
    Dec 2013
    Location
    Melbourne, Australia
    Posts
    26

    jQuery focus() handler not triggering.

    I am at a loss to figure this out. I've spent the last 2 hours pulling out my hair so hopefully someone here can help.

    I have a series of inputs which I have tried to bind a focus() event to so that I can determine which one is being clicked...

    Nothing I do can give me what I want (I started with the bind('input',function) and that failed so I've tried to go a step back to something a little more widely used and I'm still having issues... Help!?

    The alert is never triggering and there are no javascript errors appearing in the chrome console?

    Code:
    $("input.avail-hr-adjust-input").focus(function(){
    	alert($(this).attr('id'));		
    });
    HTML Code:
    <input type="text" class="avail-hr-adjust-input" id="2602" name="2602" value="0.0" onchange="changeBtnState('2602')">
    <input type="text" class="avail-hr-adjust-input" id="5245" name="5245" value="0.0" onchange="changeBtnState('5245')">
    <input type="text" class="avail-hr-adjust-input" id="1234" name="1234" value="0.0" onchange="changeBtnState('1234')">
    <input type="text" class="avail-hr-adjust-input" id="5456" name="5456" value="0.0" onchange="changeBtnState('5456')">
    <input type="text" class="avail-hr-adjust-input" id="6654" name="6654" value="0.0" onchange="changeBtnState('6654')">
    <input type="text" class="avail-hr-adjust-input" id="6598" name="6598" value="0.0" onchange="changeBtnState('6598')">
    <input type="text" class="avail-hr-adjust-input" id="8542" name="8542" value="0.0" onchange="changeBtnState('8542')">
    <input type="text" class="avail-hr-adjust-input" id="6842" name="6842" value="0.0" onchange="changeBtnState('6842')">
    <input type="text" class="avail-hr-adjust-input" id="2576" name="2576" value="0.0" onchange="changeBtnState('2576')">
    I also tried wrapping the focus() event in $(document).ready(function(){ }); but still nothing!
    Last edited by php-bgrader; 02-18-2014 at 11:26 PM.

  2. #2
    Join Date
    Feb 2014
    Location
    Managua, Nicaragua
    Posts
    38
    This work 4 me

    Code:
    <script>
    jQuery(document).ready(function($){
    	$("input").focus(function(){
    		alert($(this).attr('id'));		
    	});
    })
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles