Jump to content

jQuery Click function doesn't activate


Silvar

Recommended Posts

I've made this script. When i click the "#name_$gId" <div> where $gId is a unique id, it doesn't change any variables.

- I've tried debugging by putting in an "alert();" to see if anything gets activated at all, but it doesn't.

- I've looked up several places and the click function should written as it is.

- I've looked at the echoed sourcecode at my page with "show source" and the "#name_$gId" fits both in the script and at the <div> which should activate my script.

 

echo <<< END
<script type="text/javascript">
$("#name_$gId").click(function() {
$(function() {
$('[name=debtForm]').get('debtForm').setAttribute('action', 'scms_actions.php?id=$_GET[id]&what=debt&do=edit&which=$editWhich');
$('[name=debtName]').val('$gName');
$('[name=debtAmount]').val('$gAmount');

$('[name=withdrawDeposit]').attr('readonly', false);
$('[name=debtName]').attr('readonly', true);
});
});
</script>
END;

Link to comment
https://forums.phpfreaks.com/topic/272772-jquery-click-function-doesnt-activate/
Share on other sites

A few comments:

 

1) It's best to only use alphanumeric characters, underscores and hyphens in your IDs. Consider it a best practice. You may find that it will work with $ signs like you are using but this may cause problems in various javascript libraries or browsers.

2) .get('debtForm') will look for an element of type <getForm>, which doesn't exist.

3) You are using the [] selector without specifying a type of element. Try changing $('[name=debtName]') to something like $('input[name=debtName]')

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.