473,473 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

An onclick handler like jQuery

22 New Member
In jQuery when I add onclick attribute for an element it doesn't add this attribute, but it works. So how does it works?
Jan 28 '10 #1
6 3592
Dormilich
8,658 Recognized Expert Moderator Expert
if you add anything via JavaScript, it doesn’t show up in the source code. and although I don’t know jQuery, I expect them to use Event Handlers.
Jan 28 '10 #2
Lagon666
22 New Member
Thanks Dormilich

But if you had Firebug installed on Firefox you can see ondemand edits in page source. (by using Inspect Element)

if you run this code it will add in source coder:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("my_element").onclick = 'function(){ alert("Hello!"); }';
  2.  
But when i use jQuery it doesn't add anything to page souce.
Jan 28 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
as I said, if jQuery uses Event Handlers (that’s not event attributes), you won’t see anything in the code.
Jan 28 '10 #4
Lagon666
22 New Member
Well
Can you aid me to know more about this Event Handlers. How can i create something this?
Jan 28 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
the standard way to create event handlers:
Expand|Select|Wrap|Line Numbers
  1. elem.addEventListener("event", callback, capture);
  2. // elem - the HTML element concerned
  3. // event - event type (e.g. "click")
  4. // callback - the name of the function to execute
  5. // capture - boolean indicating whether to fire in capturing or bubbling phase
Jan 28 '10 #6
Lagon666
22 New Member
Great, Thanks man!!!
Jan 28 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
2
by: Peter | last post by:
I would like to use code like the following: this.onclick = function(e) { alert("I'm in the onclick handler"); } But I do not want to wipe out any existing onclick event code. I want to do...
4
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of...
10
by: Carlos Araya | last post by:
I have the following link on a web page <p class="menuitem"><a href="#" onclick="loadFragment('http://rivendellweb.net/fortress/home', 'index')" title="The Fortress Home">The Fortress...
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
17
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/this-alert.html http://www.frostjedi.com/terra/scripts/demo/this-alert2.html Why, when you click in the black box, do the alert boxes say different...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
5
by: dangt85 | last post by:
Hello, I have the following page: ... <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
1
omerbutt
by: omerbutt | last post by:
hi i am trying to bond an onclick function of jGrowl but it is not working iit was initially used as the document ready function and i am changing it to use it on click here is the code <!DOCTYPE...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.