?
Solved

How to use a jquery function from file with.js extenation

Posted on 2011-10-06
7
Medium Priority
?
275 Views
Last Modified: 2012-05-12
Hello,
I have a j query function I'm currently using in my page inline the code I want to be able to add it to a file I already have in the application that contains java script function
(jsfunction.js)
When Im just adding it its not working I guess I need to use somewhere
"http://code.jquery.com/jquery.js"></script> to work with the jquery libary but where?

Thank you!
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>

      <script type="text/javascript">

   function for(){
}

Open in new window

0
Comment
Question by:Nura111
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 36927672
Can you show how you have implemented it within jsfunction.js?
0
 

Author Comment

by:Nura111
ID: 36927721
I just added it to the file as it was when it was inline
function togglePopUp(element){

				var element =  $('#' + element);

				if (element.is(':hidden')){		  	

				element.toggle();

				}	

			}

Open in new window

0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 36927860
Try:

$("#popup-trigger").click(
	function() 
	{
		togglePopUp('popup');	
	}
);

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Nura111
ID: 36927866
I dont understand this code is working Im not looking fir a diffent code please explain why do i need ot change it
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 36928031
Your code show how the function is defined, I meant to suggest a way in which it can be called. Can you show me how you currently call this function?
0
 

Author Comment

by:Nura111
ID: 36928034
$emailCode = "javascript:togglePopUp('popup_form_{$id}');";

<tr class="lead_row" bgcolor="<?php echo $color;?>" style="cursor: pointer;" onclick="<?php echo $emailCode ?>">
0
 
LVL 11

Accepted Solution

by:
Ovid Burke earned 2000 total points
ID: 36928257
OK... Let me ask... Do you encounter any errors after defining your function within the jstfunction.js file and then loading the HTML/PHP page?

Once you *.js files are loaded...
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" src="path/to/your/jsfunction.js"></script>

Open in new window

... then the directive can still be the same as it is in you tr tag with the onclick attribute.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 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