Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-19-2006, 11:50 AM DOM help needed!!
Average Talker

Posts: 16
Trades: 0
Please my codes!

It doesn't response.
Code:
<html>
<head>
<title>DOM</title>
<script language = "javascript">
  
   function run() 
   {
     var x = document.getElementById("p1")
     alert("I am a " + x.tagName + " element")
   }
</script>
</head>
 
</body>
<p id = "p1"
 style = "position: absolute; left: 0; top:0;
          font-family: serif; color: blue">
<onclick="run()">Start!</p>
</html>

Last edited by vangogh; 10-19-2006 at 06:13 PM..
zhshqzyc is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-19-2006, 06:16 PM Re: DOM help needed!!
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
The onclick event handler works on links. It's not it's own tag. You can try:

<a href="" id="p1" style="position: absolute; left: 0; top:0; font-family: serif; color: blue" onclick="run()">Start!</a>

Better would be to have all the css in either the head of the page or in an external document, but I think the above line of code should work.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 10-19-2006, 06:17 PM Re: DOM help needed!!
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
probably because the > next to the blue" and the < next to the onclick.

I just tried it and it now works
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 10-19-2006, 06:35 PM Re: DOM help needed!!
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I wasn't sure if it would work on the paragraph without the link, but that's cool if it does. The problem really was that onclick isn't a tag, but is used as an attribute to a tag.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 10-21-2006, 01:26 AM Re: DOM help needed!!
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
I think onclick event handler doesnot work with paragraph it works with anchor tags and other buttons.
seomumbai is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to DOM help needed!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61800 seconds with 12 queries