1,105,310 Community Members

Click/focus/etc doesnt work on a input field

Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

Hello

Im trying to modify something when clicking on a input text field. The id of that field is cart[1223686][qty].

Tried your standard:

$j("#cart[1223686][qty]").click(function() {
alert("Handler for .click() called.");
});

But nothing. What is wrong?

(Yes, $j is correct)

Member Avatar
gon1387
Posting Whiz in Training
242 posts since Jan 2011
Reputation Points: 22 [?]
Q&As Helped to Solve: 38 [?]
Skill Endorsements: 4 [?]
 
1
 

jQuery thinks you're looking for #cart with attributes [1223686][qty].

if you want to look for that element, you have to specify the id attribute and value instead. Like this :

$j("[id='cart[1223686][qty]']").click(function() {
    alert("Handler for .click() called.");
});
Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

Worked perfectly. Stupid jQuery. Thanks.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article