Solved

click event

Posted on 2013-07-01
4
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

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…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
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…

724 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