Solved

click event

Posted on 2013-07-01
4
259 Views
Last Modified: 2013-07-01
The iphosting site should function like the seodhost site... but i put some code for the "+" sign to click and toggle like the seodhost site but it does not...there is no error in the console either so im not sure why this is happening.

http://iphosting.info/about/index.html

<script type="text/javascript">
//$(document).ready(function(){
	$("#title").bind("click",function(){

		alert('hello');
	});
//});


</script>

Open in new window






http://www.seodhost.com/about/index.html
0
Comment
Question by:Moizsaif123
  • 3
4 Comments
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
Your 'document ready' block is commented out !
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
Comment Utility
Hmmm - just looked at the code for both sites and the code you've posted above is not what is used for the + click. On the seodhost site you have the following in the head:

<script type="text/javascript">
   function CallShowHideDivContentAboutUs(id_about) {
      //Show div and reset all others
      $("#"+id_about).slideToggle(975).siblings(id_about).slideUp("slow");
   }
</script>

Open in new window

You don't have that in the other site.
0
 
LVL 4

Author Comment

by:Moizsaif123
Comment Utility
This solution works although it should work with the code below as well...not sure why..

$("#bg_about").click(function()
alert('hello');
});

Open in new window

0
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
The code you've posted above is missing an opening curly bracket. It should be:

$("#bg_about").click(function() {
     alert('hello');
});

Open in new window

Rather than adding a click event to each title, why not just add the event based on class, and attach the event in jQuery rather than the inline onClick event. It keeps it all alot neater. Have a play with this:

http://jsfiddle.net/ChrisStanyon/rraPE/
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now