Solved

click event

Posted on 2013-07-01
4
260 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 43

Expert Comment

by:Chris Stanyon
ID: 39289991
Your 'document ready' block is commented out !
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39290028
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
ID: 39290230
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 43

Expert Comment

by:Chris Stanyon
ID: 39290253
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

776 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