New to JQuery and hope this question has an easy solution. At present I am trying to assign a global variable from a function which is called on a mouseover event, fired by going over a hyperlink with a specific class.
I am trying to declare a variable inside a function and use it later on in my code... but it just already returns white space... i.e. not variable value. I am setting it within this function:
function show_video1(){ document.getElementById('video1').style.display="block"; var video1Name = "Education World News (Part 1)"; document.getElementById('video2').style.display="none"; document.getElementById('video3').style.display="none"; document.getElementById('video4').style.display="none"; [Code]...
and trying to call it later on with this: <script type="text/javascript">document.write(video1Name)</script> It might be worth noting that each one of my 11 videos will hace a different name.
So I've got this checkbox thing going on, where an array converted with the value of each checkbox in it.It looks like this:
[Code]...
What I want out of this function is the variable newworkdays to use in another function.
How do I access the "newworkdays" outside the function? I've already try to declare the variable outside of the function, though that resulted in that I didn't get the value of the variable inside the function.
I'd like to trick the .get function and use a variable, instead of an url.I already know what the link will be - linker - but I can't pass it to jQuery, it doesn't work...
what I should do to use the get function like this:
At present I am trying to assign a global variable from a function which is called on a mouseover event, fired by going over a hyperlink with a specific class.
The code:
[b]active = "false" $('.menulink').mouseover( function(active) { active = "true"
$("#ltr").live("mouseover", function() { //swap class names $("div#container").removeClass("rtl").addClass("ltr"); }); I run this function to swap class names when there is a mouseover event on an image with the ID "ltr". How would I run this same function but to occur when, for example, a variable "distance" was equal to 0? Basically, if distance = 0 then swap class names
if this is such a obvious question, but i'm kind of newbie in JQuery, i am using a lightpop plugin, & i want to pass 'image_path' via html. lightpop plugin code is something like this:
Let's say I have this function: function add(x, y) { var add = x + y;
[Code]...
So let's say the value of select_first is "1", and value of select_second is also "1". But when they are passed to the add function, the returned value is 11 and not 2. So what I understood is that it took the values as strings instead of integers. What should I do so that select_first and select_second are integers instead of string?
As it is shown in line 2 does everything perfectly, but I must declare the variable outside the function, as it implies the following code (line 1). marcel var wert = "text"; $('#bChange' ).click(function() { $.ajax({ url:"content/nextpage.php", type:"POST", timeout: 5000, dataType:'html', cache:false, data: { rNeuRecht: wert }, success:function (msg){ $("#leer").html(msg); }});}); $('#bChange' ).click(function () { $.ajax({ url:"content/nextpage.php", type:"POST", timeout: 5000, dataType:'html', cache:false, data: { rNeuRecht: "text" }, success:function (msg){ $("#leer" ).html(msg); }});});
I have a bit of php that creates an entry on a page for each row in a table, some pages may have multiple entries, others just one.
eg.
<h2 class="title">{title}</h2> {summary} <p onclick="openBox({entry_id})">Click to read more ></p> <div id="{entry_id}" style="display:hidden;">{body}</div>
I would like to have just one function to open and close all individually, eg.
$(document).ready(function(){ function openBox(id){ if ($("#id:first").is(":hidden")) {
[Code].....
Well I know I'm doing something wrong as this is not working, and I don't know how better to explain I hope this is sufficient, I'm not worrried about the php/html bit as that is working fine.
Pass variable to jQuery function in another page? I have what I think is a simple question but I can't find an answer. I have two html pages - one.html, two html. [URL] one.html contains a jquery function that alerts the variable it is passed.
[Code]...
The problem is I want to call and pass the variable from another html page - two.html How can I call and pass a variable to the jQuery function in one.html from two.html ?
I've set up a jsfiddle here [URL]I've been working to reduce my problem to the basics, the end application is a bit more complex and I'm pulling data into the array dynamically using a query from our BI tool.
I'm trying to get the hidden div's to show/animate using the mousedown on the outer DIV. The second example (Belknap2) works (just click the div) because I've typed the code into the mouseover (which is the same text which the variable x results in).
When I try to make this a bit more dynamic, e.g., by calling the variable rather than typing the expression into the mouseover in the first example, it doesn't run.
I want to modify a local variable of the ready function set like so: $(function () { var modifyme = 0; ... }); I cant change the code setting the ready function, as I am writing only a greasemonkey userscript. I already tried using the .data("events") method, but it never listed the "ready" event. Any function so I can modify the variable!
I have a function which has a nested function in it. I need some variables in the first function to be available in the nested function. How am I supposed to declare a global variable in jquery?
I've got a number of divs with the prefix menu and the suffix where is say 1-10. My code is below. It assigns the click function fine to each, but assigns them all the function based on the last value of the for loop. (It calls the current value, while I want the value from when the code was originally executed to set up the click function). Scratching my head on how to accomplish this.$(function(){
I'm trying to fetch JSON contents via ajax() from a file using this code: // grab pages via AJAX request sm.pages = (function() { var json = null; $.ajax({ async: false, global: false, url: 'pages.json', dataType: 'json', success: function(data){ json = data; console.log(data); }}); return json; })(); One problem though. The success function doesn't seem to be firing at all even though I can see the request was successfully in Firebug.
I can't seem to get a variable declared from within a post callback, so that I could manipulate my script accordingly. I have delete.php, that deletes an id from a mysql db. If it fails, I want the script to stop and display the error. The .php script echos an "ok" if everything went fine, if not - it echos the error.var abort_error; // set the error variable
Two objects on an html page. An event on object 1 effects object 2 $(".video_rg").mouseover(function(event){ var myTriggerId = event.target.id; var myTargetId = 'video_' + myTriggerId; document.getElementById(myTargetId).src = 'images/test_object_2.gif'; // this works // $('#myTargetId').src = 'images/test_object_2.gif'; // this does not }); My assumption (we know about those) is that I am not passing the data to the $() function correctly, that it is reading '#myTargetId' as a string, and not a variable. I just really want the JQuery code that would do what the document.getElementById code is doing.