jquery

unable to set the html content in a custom jQuery function

Hi, I have a jQuery function called "bindServingSizes" which I call like this $(servingsizes).bindServingSizes(ingredientid); Where "servingsizes" is a valid drop down list control. jQuery.fn.bindServingSizes = function(ingredientid) { $.getJSON("/serving_sizes?ingredientid=" + ingredientid, function(j) { var options ...

help with jquery update content in html

i use jquery ajax to get data from php file. data = <option>Peter</option><option>Maria</option> i want to then use jquery to put this data after the first option <select> <option>Name</option> </select> i cant use html() on select because then the first option will be deleted. what jquery function can i use to put them after th...

JQuery not working in Firefox, does in Safari

Hi all, I'm building a site using Jquery for some basic animation. The javascript is here: $(document).ready(initialize); var currentSelection = null; var previousSelection = null; function initialize() { $("#print").bind("mouseover", navHover); $("#print").bind("mouseout", navStby); $("#print").bind("click", selectPrint); $("#radio...

jQuery syntax question (getting the ID of a link)

I have a series of links, each with their own id: <li><a id="about" href="#">About</a></li> <li><a id="call-us" href="#">Contact us</a></li> <li><a id="home" href="#">Head on home</a></li> Instead of writing a series of statements like this: $(document).ready(function(){ $("a.about").click(function(event){ $("#content").l...

Getting started with jQuery

What is a good place to start playing with jQuery, besides the jQuery website. I'm having trouble with the way the site is set up - I dislike it. ...

jQuery scroll div with scrollTop

I'm trying to scroll a div up or down when hovering over the respective arrows. I also want to be able to jump down the div when the buttons are clicked (think clicking the windows scroll arrows rather than dragging the scroll bar). The scrolling works but the jumping doesn't. scrollTop() keeps retuning 0. Here's the code: function st...

Best way to unselect a <select> in jQuery?

<select size="2"> <option selected="selected">Input your option</option> <option>Input your option</option> </select> How to do it elegantly? ...

jquery hover image fade swap

I have been searching online for awhile, trying to find the best way to write a jquery script that does this simple task: swapping an image on hover with an elegant fade effect. I have found many solutions (some way to cumbersome and clunky), and narrowed it down to what I see as the two best: http://designwoop.com/2009/08/image-hover-e...

Why isn't this callback resolving properly in jQuery?

I have this code: $(document).ready(function(){ $(".links a").click(function(e){ var toLoad = "products.html #" + this.id; $('#block').fadeTo('fast',0,loadContent); function loadContent() { $('#block').load(toLoad,'',showNewContent()) } function showNewContent() { ...

ajax and codeigniter duplicating header

I have a strange problem that I am unable to track down. I am using Codeigniter and Jquery to create an ajax search feature. Everything is working well and the correct data is been returned from my model but when I load the view from the controller it has the header of the page in the response. I have tried an empty view to load and st...

How to get first parent of span that is a <p> in jQuery?

As per this page says: Find all parent elements of each span that is a paragraph. How to get the first one that matches? ...

Removing all line-breaks (BRs)

I'd like to remove all <br/> <br /> or <br> tags from #id p. I tried $('#id p').find('br').remove(); but it doesn't seem to work. EDIT: Ah, I was accessing the element by ID, and it was a CLASS, uh! :) So $('#id p').find('br').remove(); works fine! ...

What am I doing wrong with JQueryUI's tabs feature?

I feel really silly for asking this, but what am I doing wrong with http://www.wcarsucks.com? I followed their example exactly, no dice. ...

How to know index of a <tr> inside a <table> with jQuery?

I'm now implementing something like this post, the effect takes place when the row is clicked, the problem is now:how do I know what the index of the row is inside the table? ...

How to find <tr> inside <table> with depth 1?

$(this).parents('table:first').find('tr')) The above will search for tr inside table recursively,how to make it only search for the top tr? EDIT children is not working as expected: alert($(this).parents('table:first').children('tr').length) gives 0 ...

sending back json string with echo problem

i use json_encode to send back data from php to jquery through ajax. and i have noticed that jquery just allow us to use ONE echo in php. if i use echo json_encode($array);.... and then one more echo json_encode($array2); in the same php file, then it would not work. or if i use echo json_encode($array); and then another echo "hello";...

Basic image rotation with jQuery

I'd like to test banner (two css background images) and rotate them randomly on each page reload. Is it possible to achieve something like that without using any plugins? I just need to rotate two images, which is basically just swapping css classes randomly on the banner element, on each reload. Many thanks. ...

jquery executes declared function without me clicking

i wonder why the browser displays "logged in" without me having clicked on the link i id-tagged with clickhere. it displays it everytime i refreshes the page. <script type="text/javascript"> $(document).ready(function(){ function login(){ alert("logged in"); } $("#clickhere").click(login()); }); </script> i ju...

javascript scope issue

Code snippet as follows: $(this).parents('td:first').next().find('option').customizeMenu('myMenu2'); This works,but : var listener = function(){ $(this).parents('td:first').next().find('option').customizeMenu('myMenu2'); }; listener(); is not working,why and how to fix it? ...

jQuery checkbox manipulation

I have a list of checkboxes, looking like this: <table> <tr><td><input type="checkbox" /> <label>Bla</label></td></tr> <tr><td><input type="checkbox" /> <label> + Bla Sub 1</label></td></tr> <tr><td><input type="checkbox" /> <label> + Bla Sub 2</label></td></tr> <tr><td><input type="checkbox" /> <label> + Bla Sub 3</label></td></tr>...