Search Results

Search found 17401 results on 697 pages for 'jquery selectors'.

Page 5/697 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Best method to select an object from another unknown jQuery object

    - by Yosi
    Lets say I have a jQuery object/collection stored in a variable named obj, which should contain a DOM element with an id named target. I don't know in advance if target will be a child in obj, i.e.: obj = $('<div id="parent"><div id="target"></div></div>'); or if obj equals target, i.e.: obj = $('<div id="target"></div>'); or if target is a top-level element inside obj, i.e.: obj = $('<div id="target"/><span id="other"/>'); I need a way to select target from obj, but I don't know in advance when to use .find and when to use .filter. What would be the fastest and/or most concise method of extracting target from obj? What I've come up with is: var $target = obj.find("#target").add(obj.filter("#target")); UPDATE I'm adding solutions to a JSPERF test page to see which one is the best. Currently my solution is still the fastest. Here is the link, please run the tests so that we'll have more data: http://jsperf.com/jquery-selecting-objects

    Read the article

  • How to get jQuery to find the first list-item, rather than all list-items?

    - by ricebowl
    I'm trying to implement a basic jQuery infinite carousel. As much for the learning process as for anything else (as a rule I'm not a fan of re-inventing wheels, but...I have to learn somehow, might as well start with the basics). I've managed to get the list to animate left happily enough, but I'm stuck when it comes to selecting the first element of the list. I've tried to use: $('ul#services > li:first'); $('ul#services > li:first-child'); $('ul#services > li').eq([0]); (xhtml below), In each case a console.log(first) (the var name used) returns all of the list-items. Am I doing something blatantly, and obviously, wrong? The eventual plan is to clone the first li, append it to the parent ul, remove the li from the list and allow the list to scroll infinitely. It's just a list of services rather than links so I'm not -at the moment- planning to have scroll or left/right functionality. Current xhtml: <div class="wrapper"> <ul id="services"> <!-- closing the `</li>` tags on the following line is to remove whitespace in the horizontal list, doesn't seem to make a difference to the jQuery from my own testing. --> <li>one</li ><li>two</li ><li>three</li ><li>four</li ><li>five</li ><li>six</li ><li>seven</li ><li>eight</li ><li>nine</li ><li>ten</li> </ul> </div>

    Read the article

  • Metro: Query Selectors

    - by Stephen.Walther
    The goal of this blog entry is to explain how to perform queries using selectors when using the WinJS library. In particular, you learn how to use the WinJS.Utilities.query() method and the QueryCollection class to retrieve and modify the elements of an HTML document. Introduction to Selectors When you are building a Web application, you need some way of easily retrieving elements from an HTML document. For example, you might want to retrieve all of the input elements which have a certain class. Or, you might want to retrieve the one and only element with an id of favoriteColor. The standard way of retrieving elements from an HTML document is by using a selector. Anyone who has ever created a Cascading Style Sheet has already used selectors. You use selectors in Cascading Style Sheets to apply formatting rules to elements in a document. For example, the following Cascading Style Sheet rule changes the background color of every INPUT element with a class of .required in a document to the color red: input.red { background-color: red } The “input.red” part is the selector which matches all INPUT elements with a class of red. The W3C standard for selectors (technically, their recommendation) is entitled “Selectors Level 3” and the standard is located here: http://www.w3.org/TR/css3-selectors/ Selectors are not only useful for adding formatting to the elements of a document. Selectors are also useful when you need to apply behavior to the elements of a document. For example, you might want to select a particular BUTTON element with a selector and add a click handler to the element so that something happens whenever you click the button. Selectors are not specific to Cascading Style Sheets. You can use selectors in your JavaScript code to retrieve elements from an HTML document. jQuery is famous for its support for selectors. Using jQuery, you can use a selector to retrieve matching elements from a document and modify the elements. The WinJS library enables you to perform the same types of queries as jQuery using the W3C selector syntax. Performing Queries with the WinJS.Utilities.query() Method When using the WinJS library, you perform a query using a selector by using the WinJS.Utilities.query() method.  The following HTML document contains a BUTTON and a DIV element: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Application1</title> <!-- WinJS references --> <link href="//Microsoft.WinJS.0.6/css/ui-dark.css" rel="stylesheet"> <script src="//Microsoft.WinJS.0.6/js/base.js"></script> <script src="//Microsoft.WinJS.0.6/js/ui.js"></script> <!-- Application1 references --> <link href="/css/default.css" rel="stylesheet"> <script src="/js/default.js"></script> </head> <body> <button>Click Me!</button> <div style="display:none"> <h1>Secret Message</h1> </div> </body> </html> The document contains a reference to the following JavaScript file named \js\default.js: (function () { "use strict"; var app = WinJS.Application; app.onactivated = function (eventObject) { if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { WinJS.Utilities.query("button").listen("click", function () { WinJS.Utilities.query("div").clearStyle("display"); }); } }; app.start(); })(); The default.js script uses the WinJS.Utilities.query() method to retrieve all of the BUTTON elements in the page. The listen() method is used to wire an event handler to the BUTTON click event. When you click the BUTTON, the secret message contained in the hidden DIV element is displayed. The clearStyle() method is used to remove the display:none style attribute from the DIV element. Under the covers, the WinJS.Utilities.query() method uses the standard querySelectorAll() method. This means that you can use any selector which is compatible with the querySelectorAll() method when using the WinJS.Utilities.query() method. The querySelectorAll() method is defined in the W3C Selectors API Level 1 standard located here: http://www.w3.org/TR/selectors-api/ Unlike the querySelectorAll() method, the WinJS.Utilities.query() method returns a QueryCollection. We talk about the methods of the QueryCollection class below. Retrieving a Single Element with the WinJS.Utilities.id() Method If you want to retrieve a single element from a document, instead of matching a set of elements, then you can use the WinJS.Utilities.id() method. For example, the following line of code changes the background color of an element to the color red: WinJS.Utilities.id("message").setStyle("background-color", "red"); The statement above matches the one and only element with an Id of message. For example, the statement matches the following DIV element: <div id="message">Hello!</div> Notice that you do not use a hash when matching a single element with the WinJS.Utilities.id() method. You would need to use a hash when using the WinJS.Utilities.query() method to do the same thing like this: WinJS.Utilities.query("#message").setStyle("background-color", "red"); Under the covers, the WinJS.Utilities.id() method calls the standard document.getElementById() method. The WinJS.Utilities.id() method returns the result as a QueryCollection. If no element matches the identifier passed to WinJS.Utilities.id() then you do not get an error. Instead, you get a QueryCollection with no elements (length=0). Using the WinJS.Utilities.children() method The WinJS.Utilities.children() method enables you to retrieve a QueryCollection which contains all of the children of a DOM element. For example, imagine that you have a DIV element which contains children DIV elements like this: <div id="discussContainer"> <div>Message 1</div> <div>Message 2</div> <div>Message 3</div> </div> You can use the following code to add borders around all of the child DIV element and not the container DIV element: var discussContainer = WinJS.Utilities.id("discussContainer").get(0); WinJS.Utilities.children(discussContainer).setStyle("border", "2px dashed red");   It is important to understand that the WinJS.Utilities.children() method only works with a DOM element and not a QueryCollection. Notice that the get() method is used to retrieve the DOM element which represents the discussContainer. Working with the QueryCollection Class Both the WinJS.Utilities.query() method and the WinJS.Utilities.id() method return an instance of the QueryCollection class. The QueryCollection class derives from the base JavaScript Array class and adds several useful methods for working with HTML elements: addClass(name) – Adds a class to every element in the QueryCollection. clearStyle(name) – Removes a style from every element in the QueryCollection. conrols(ctor, options) – Enables you to create controls. get(index) – Retrieves the element from the QueryCollection at the specified index. getAttribute(name) – Retrieves the value of an attribute for the first element in the QueryCollection. hasClass(name) – Returns true if the first element in the QueryCollection has a certain class. include(items) – Includes a collection of items in the QueryCollection. listen(eventType, listener, capture) – Adds an event listener to every element in the QueryCollection. query(query) – Performs an additional query on the QueryCollection and returns a new QueryCollection. removeClass(name) – Removes a class from the every element in the QueryCollection. removeEventListener(eventType, listener, capture) – Removes an event listener from every element in the QueryCollection. setAttribute(name, value) – Adds an attribute to every element in the QueryCollection. setStyle(name, value) – Adds a style attribute to every element in the QueryCollection. template(templateElement, data, renderDonePromiseContract) – Renders a template using the supplied data.  toggleClass(name) – Toggles the specified class for every element in the QueryCollection. Because the QueryCollection class derives from the base Array class, it also contains all of the standard Array methods like forEach() and slice(). Summary In this blog post, I’ve described how you can perform queries using selectors within a Windows Metro Style application written with JavaScript. You learned how to return an instance of the QueryCollection class by using the WinJS.Utilities.query(), WinJS.Utilities.id(), and WinJS.Utilities.children() methods. You also learned about the methods of the QueryCollection class.

    Read the article

  • DevConnections jQuery Session Slides and Samples posted

    - by Rick Strahl
    I’ve posted all of my slides and samples from the DevConnections VS 2010 Launch event last week in Vegas. All three sessions are contained in a single zip file which contains all slide decks and samples in one place: www.west-wind.com/files/conferences/jquery.zip There were 3 separate sessions: Using jQuery with ASP.NET Starting with an overview of jQuery client features via many short and fun examples, you'll find out about core features like the power of selectors to select document elements, manipulate these elements with jQuery's wrapped set methods in a browser independent way, how to hook up and handle events easily and generally apply concepts of unobtrusive JavaScript principles to client scripting. The session also covers AJAX interaction between jQuery and the .NET server side code using several different approaches including sending HTML and JSON data and how to avoid user interface duplication by using client side templating. This session relies heavily on live examples and walk-throughs. jQuery Extensibility and Integration with ASP.NET Server Controls One of the great strengths of the jQuery Javascript framework is its simple, yet powerful extensibility model that has resulted in an explosion of plug-ins available for jQuery. You need it - chances are there's a plug-in for it! In this session we'll look at a few plug-ins to demonstrate the power of the jQuery plug-in model before diving in and creating our own custom jQuery plug-ins. We'll look at how to create a plug-in from scratch as well as discussing when it makes sense to do so. Once you have a plug-in it can also be useful to integrate it more seamlessly with ASP.NET by creating server controls that coordinate both server side and jQuery client side behavior. I'll demonstrate a host of custom components that utilize a combination of client side jQuery functionality and server side ASP.NET server controls that provide smooth integration in the user interface development process. This topic focuses on component development both for pure client side plug-ins and mixed mode controls. jQuery Tips and Tricks This session was kind of a last minute substitution for an ASP.NET AJAX talk. Nothing too radical here :-), but I focused on things that have been most productive for myself. Look at the slide deck for individual points and some of the specific samples.   It was interesting to see that unlike in previous conferences this time around all the session were fairly packed – interest in jQuery is definitely getting more pronounced especially with microsoft’s recent announcement of focusing on jQuery integration rather than continuing on the path of ASP.NET AJAX – which is a welcome change. Most of the samples also use the West Wind Web & Ajax Toolkit and the support tools contained within it – a snapshot version of the toolkit is included in the samples download. Specicifically a number of the samples use functionality in the ww.jquery.js support file which contains a fairly large set of plug-ins and helper functionality – most of these pieces while contained in the single file are self-contained and can be lifted out of this file (several people asked). Hopefully you'll find something useful in these slides and samples.© Rick Strahl, West Wind Technologies, 2005-2010Posted in ASP.NET  jQuery  

    Read the article

  • jQuery and Windows Azure

    - by Stephen Walther
    The goal of this blog entry is to describe how you can host a simple Ajax application created with jQuery in the Windows Azure cloud. In this blog entry, I make no assumptions. I assume that you have never used Windows Azure and I am going to walk through the steps required to host the application in the cloud in agonizing detail. Our application will consist of a single HTML page and a single service. The HTML page will contain jQuery code that invokes the service to retrieve and display set of records. There are five steps that you must complete to host the jQuery application: Sign up for Windows Azure Create a Hosted Service Install the Windows Azure Tools for Visual Studio Create a Windows Azure Cloud Service Deploy the Cloud Service Sign Up for Windows Azure Go to http://www.microsoft.com/windowsazure/ and click the Sign up Now button. Select one of the offers. I selected the Introductory Special offer because it is free and I just wanted to experiment with Windows Azure for the purposes of this blog entry.     To sign up, you will need a Windows Live ID and you will need to enter a credit card number. After you finish the sign up process, you will receive an email that explains how to activate your account. Accessing the Developer Portal After you create your account and your account is activated, you can access the Windows Azure developer portal by visiting the following URL: http://windows.azure.com/ When you first visit the developer portal, you will see the one project that you created when you set up your Windows Azure account (In a fit of creativity, I named my project StephenWalther).     Creating a New Windows Azure Hosted Service Before you can host an application in the cloud, you must first add a hosted service to your project. Click your project on the summary page and click the New Service link. You are presented with the option of creating either a new Storage Account or a new Hosted Services.     Because we have code that we want to run in the cloud – the WCF Service -- we want to select the Hosted Services option. After you select this option, you must provide a name and description for your service. This information is used on the developer portal so you can distinguish your services.     When you create a new hosted service, you must enter a unique name for your service (I selected jQueryApp) and you must select a region for this service (I selected Anywhere US). Click the Create button to create the new hosted service.   Install the Windows Azure Tools for Visual Studio We’ll use Visual Studio to create our jQuery project. Before you can use Visual Studio with Windows Azure, you must first install the Windows Azure Tools for Visual Studio. Go to http://www.microsoft.com/windowsazure/ and click the Get Tools and SDK button. The Windows Azure Tools for Visual Studio works with both Visual Studio 2008 and Visual Studio 2010.   Installation of the Windows Azure Tools for Visual Studio is painless. You just need to check some agreement checkboxes and click the Next button a few times and installation will begin:   Creating a Windows Azure Application After you install the Windows Azure Tools for Visual Studio, you can choose to create a Windows Azure Cloud Service by selecting the menu option File, New Project and selecting the Windows Azure Cloud Service project template. I named my new Cloud Service with the name jQueryApp.     Next, you need to select the type of Cloud Service project that you want to create from the New Cloud Service Project dialog.   I selected the C# ASP.NET Web Role option. Alternatively, I could have picked the ASP.NET MVC 2 Web Role option if I wanted to use jQuery with ASP.NET MVC or even the CGI Web Role option if I wanted to use jQuery with PHP. After you complete these steps, you end up with two projects in your Visual Studio solution. The project named WebRole1 represents your ASP.NET application and we will use this project to create our jQuery application. Creating the jQuery Application in the Cloud We are now ready to create the jQuery application. We’ll create a super simple application that displays a list of records retrieved from a WCF service (hosted in the cloud). Create a new page in the WebRole1 project named Default.htm and add the following code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Products</title> <style type="text/css"> #productContainer div { border:solid 1px black; padding:5px; margin:5px; } </style> </head> <body> <h1>Product Catalog</h1> <div id="productContainer"></div> <script id="productTemplate" type="text/html"> <div> Name: {{= name }} <br /> Price: {{= price }} </div> </script> <script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script> <script src="Scripts/jquery.tmpl.js" type="text/javascript"></script> <script type="text/javascript"> var products = [ {name:"Milk", price:4.55}, {name:"Yogurt", price:2.99}, {name:"Steak", price:23.44} ]; $("#productTemplate").render(products).appendTo("#productContainer"); </script> </body> </html> The jQuery code in this page simply displays a list of products by using a template. I am using a jQuery template to format each product. You can learn more about using jQuery templates by reading the following blog entry by Scott Guthrie: http://weblogs.asp.net/scottgu/archive/2010/05/07/jquery-templates-and-data-linking-and-microsoft-contributing-to-jquery.aspx You can test whether the Default.htm page is working correctly by running your application (hit the F5 key). The first time that you run your application, a database is set up on your local machine to simulate cloud storage. You will see the following dialog: If the Default.htm page works as expected, you should see the list of three products: Adding an Ajax-Enabled WCF Service In the previous section, we created a simple jQuery application that displays an array by using a template. The application is a little too simple because the data is static. In this section, we’ll modify the page so that the data is retrieved from a WCF service instead of an array. First, we need to add a new Ajax-enabled WCF Service to the WebRole1 project. Select the menu option Project, Add New Item and select the Ajax-enabled WCF Service project item. Name the new service ProductService.svc. Modify the service so that it returns a static collection of products. The final code for the ProductService.svc should look like this: using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Activation; namespace WebRole1 { public class Product { public string name { get; set; } public decimal price { get; set; } } [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class ProductService { [OperationContract] public IList<Product> SelectProducts() { var products = new List<Product>(); products.Add(new Product {name="Milk", price=4.55m} ); products.Add(new Product { name = "Yogurt", price = 2.99m }); products.Add(new Product { name = "Steak", price = 23.44m }); return products; } } }   In real life, you would want to retrieve the list of products from storage instead of a static array. We are being lazy here. Next you need to modify the Default.htm page to use the ProductService.svc. The jQuery script in the following updated Default.htm page makes an Ajax call to the WCF service. The data retrieved from the ProductService.svc is displayed in the client template. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Products</title> <style type="text/css"> #productContainer div { border:solid 1px black; padding:5px; margin:5px; } </style> </head> <body> <h1>Product Catalog</h1> <div id="productContainer"></div> <script id="productTemplate" type="text/html"> <div> Name: {{= name }} <br /> Price: {{= price }} </div> </script> <script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script> <script src="Scripts/jquery.tmpl.js" type="text/javascript"></script> <script type="text/javascript"> $.post("ProductService.svc/SelectProducts", function (results) { var products = results["d"]; $("#productTemplate").render(products).appendTo("#productContainer"); }); </script> </body> </html>   Deploying the jQuery Application to the Cloud Now that we have created our jQuery application, we are ready to deploy our application to the cloud so that the whole world can use it. Right-click your jQueryApp project in the Solution Explorer window and select the Publish menu option. When you select publish, your application and your application configuration information is packaged up into two files named jQueryApp.cspkg and ServiceConfiguration.cscfg. Visual Studio opens the directory that contains the two files. In order to deploy these files to the Windows Azure cloud, you must upload these files yourself. Return to the Windows Azure Developers Portal at the following address: http://windows.azure.com/ Select your project and select the jQueryApp service. You will see a mysterious cube. Click the Deploy button to upload your application.   Next, you need to browse to the location on your hard drive where the jQueryApp project was published and select both the packaged application and the packaged application configuration file. Supply the deployment with a name and click the Deploy button.     While your application is in the process of being deployed, you can view a progress bar.     Running the jQuery Application in the Cloud Finally, you can run your jQuery application in the cloud by clicking the Run button.   It might take several minutes for your application to initialize (go grab a coffee). After WebRole1 finishes initializing, you can navigate to the following URL to view your live jQuery application in the cloud: http://jqueryapp.cloudapp.net/default.htm The page is hosted on the Windows Azure cloud and the WCF service executes every time that you request the page to retrieve the list of products. Summary Because we started from scratch, we needed to complete several steps to create and deploy our jQuery application to the Windows Azure cloud. We needed to create a Windows Azure account, create a hosted service, install the Windows Azure Tools for Visual Studio, create the jQuery application, and deploy it to the cloud. Now that we have finished this process once, modifying our existing cloud application or creating a new cloud application is easy. jQuery and Windows Azure work nicely together. We can take advantage of jQuery to build applications that run in the browser and we can take advantage of Windows Azure to host the backend services required by our jQuery application. The big benefit of Windows Azure is that it enables us to scale. If, all of the sudden, our jQuery application explodes in popularity, Windows Azure enables us to easily scale up to meet the demand. We can handle anything that the Internet might throw at us.

    Read the article

  • How to change Jquery UI Slider handle

    - by Tom
    I want to modify the stock JQuery UI slider so that the handle has a arrow on it rather than being a square. i.e. I want to use a custom image as the handle. There are a few tutorials that do it: http://jqueryfordesigners.com/slider-gallery/ http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/ http://www.keepthewebweird.com/creating-a-nice-slider-with-jquery-ui/ But I can't get it to work. The following code results in a stationary handle image: <!DOCTYPE html> <html> <head> <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" /> <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script> <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script> <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.slider.js"></script> <style type="text/css"> #myhandle {position: absolute;z-index: 100;height: 25px;width: 35px;top: auto;background: url(http://stackoverflow.com/content/img/so/vote-arrow-down.png) no-repeat;} </style> <script type="text/javascript"> $(document).ready(function(){ $("#slider").slider({handle: '#myhandle'}); }); </script> </head> <body> <div id="slider"><div id="myhandle"></div></div> </body> </html> It is as if JQuery doesn't pick up that I want to use the myhandle id for the handle. I'm wondering: Do I need a plugin for JQuery to recognise the handle option? (it is not documented in http://docs.jquery.com/UI/Slider). Or perhaps it only worked in an old version of JQuery? Any ideas?

    Read the article

  • jquery textarea validation

    - by Hulk
    How to check for null,white spaces and new lines while validating for a textarea using jquery. If the textarea is empty and has only new lines or spaces should raise an alert

    Read the article

  • jQuery: select all inputs with unique id (Regex/Wildcard Selectors)

    - by d3020
    I have some textboxes on a webform that have ids like this: txtFinalDeadline_1 txtFinalDeadline_2 txtFinalDeadline_3 txtFinalDeadline_4 In my jQuery how do I find all of those in order to assign a value to them. Before I had the underscore and they were all named txtFinalDeadline I could do this and it worked. $(this).find("#txtFinalDeadline").val(formatDate); However, that was when they were all named the same thing. Now I have the _x after the name and I'm not sure how to go about assigning that same value as before to them. Thanks.

    Read the article

  • How to write a jquery ui plugin?

    - by Haris
    I want to write a jquery ui plugin? I can't find a useful tutorial which will guide me from start. I've never written a plugin for jquery before. I want to prevent draggables from overlappping on each other. I found a plugin for jquery ui but it doesn't work with version 1.7.1 of jQuery UI Please help!

    Read the article

  • Jquery change function don’t work properly

    - by user1493448
    I have same id, name two html select. If I change first html select then it’s work properly but If I change second html select then it’s not work. Please can someone point out what I may be doing wrong here? Many thanks. Here is my code: <html> <head> <title>the title</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("#name").change(function(){ $.post( "data.php", $("#testform").serialize(), function(data) { $('#stage1').html(data); } ); var str = $("#testform").serialize(); $("#stage2").text(str); }); }); </script> </head> <body> <div id="stage1" style="background-color:blue; color: white"> STAGE - 1 </div> <form id="testform"> <table> <tr> <td><p>Fruit:</p></td> <td> <select id="name" name="name[]"> <option>Apple</option> <option>Mango</option> <option>Orange</option> <option>Banana</option> </select> </td> </tr> <tr> <td><p>Fruit:</p></td> <td> <select id="name" name="name[]"> <option>Apple</option> <option>Mango</option> <option>Orange</option> <option>Banana</option> </select> </td> </tr> </table> </form> </body> </html> Php code: <?php $fruit=$_REQUEST["name"]; $n = count($fruit); for($i=0;$i<$n; $i++) { echo $fruit[$i]."<br/>"; } ?>

    Read the article

  • Jquery selectors question

    - by Ben
    Hi all, I am not an expert at jquery but trying to get a menu to work. Basically, I have a menu made of up to 3 levels of nested lists. The first level has a little arrow has a background image that opens or close when opening the first level list. Any other nested lists don't need to have the background image. My script opens the menu when you click on it and is also supposed to switch the first level list from a class "inactive" to a class "active". Here is the script: $(document).ready(function(){ $("#left-navigation-holder ul.level1 li.inactive").toggle(function(){ $(this).addClass("active"); }, function () { $(this).removeClass("active"); }); $("#left-navigation-holder li a").click(function(){ menu = $(this).parent('li').children('ul'); menu.toggle(); }); }); The problem is that the toggle function also happens when clicking on second and third level lists causing the arrows to toggle even if the first level list isn't clicked on. I thought using $("#left-navigation-holder ul.level1 li.inactive").toggle would limit the function to the first level list with a class "inactive". Any help would be really appreciated. Ben

    Read the article

  • need help with jquery selectors

    - by photographer
    I've got code like that: <ul class="gallery_demo_unstyled"> <li class="active"><img src='001.jpg' /></li> <li><img src='002.jpg' /></li> <li><img src='003.jpg' /></li> <li><img src='004.jpg' /></li> <li><img src='005.jpg' /></li> <li><img src='006.jpg' /></li> </ul> <div class="Paginator"> <a href="../2/" class="Prev">&lt;&lt;</a> <a href="../1/">1</a> <a href="../2/">2</a> <span class="this-page">3</span> <a href="../4/">4</a> <a href="../5/">5</a> <a href="../4/" class="Next">&gt;&gt;</a> </div> <div class="Albums"><div class="AlbumsMenu"> <p><b>ALBUMS</b></p> <p><a href="../../blackandwhite/1/" >blackandwhite</a></p> <p><a href="../../color/1/" class='this-page'>>>color</a></p> <p><a href="../../film/1/" >film</a></p> <p><a href="../../digital/1/" >digital</a></p> <p><a href="../../portraits/1/" >portraits</a></p> </div></div> ...and some JavaScript/jQuery allowing to cycle through the images (the very top li elements) going back to the first image after the last one: $$.nextSelector = function(selector) { return $(selector).is(':last-child') ? $(selector).siblings(':first-child') : $(selector).next(); }; Current page is always 'this-page' class (span or p in my case, but I could change that if necessary). The question: what should I change in my code to make it go after the last image to the next page instead of cycling through the page over and over again, and after the last page to the next album? And to the first image on the first page of the first album after the last-last-last (or just stop there — don't really care)?

    Read the article

  • jQuery selecrors. help for newbie

    - by Shamanu4
    Hello. I have this code, which open new jquery-ui dialog and then hide the dialog's titlebar. <div id="keyboard" class="keyboard dialogs">...</div>   $("#keyboard").dialog({ width: 1136, height: 437, position: ['center',400], closeOnEscape: false, autoOpen: false, resizable: false, open: function(event, ui) { $(".ui-dialog-titlebar").hide(); // <-- this selector i want to change } }); But $(".ui-dialog-titlebar") select all titlebars. How do i have change selector to hide only this titlebar?

    Read the article

  • show/hide a link if certain jquery ui tab is selected.

    - by Mark
    When #my-text-link is clicked, i need to select tab 5 and when tab 5 is selected i need to hide #my-text-link. hope this makes sense, heres the code, and also what I have done so far, please feel free to show me a better way. Thanks in advance var $tabs = $('.tabbed').tabs(); // first tab selected $('#my-text-link').click(function() { // bind click event to link $tabs.tabs('select', 4); // switch to third tab $('#my-text-link').hide(); return false; }); <a href="#" id="my-text-link"></a> <ul> <li class="one"><a href="#tabs-1" title="Summary"></a></li> <li class="two"><a href="#tabs-2" title="Detailed Info"></a></li> <li class="three"><a href="#tabs-3" title="Images"></a></li> <li class="four"><a href="#tabs-4" title="Reviews"></a></li> <li class="five"><a href="#tabs-5" title="Dates &amp; Prices"></a></li> </ul> <div id="tabs-1"></div> <div id="tabs-2"></div> <div id="tabs-3"></div> <div id="tabs-4"></div> <div id="tabs-5"></div>

    Read the article

  • jQuery mobile List-View is not working after adding some jquery code [closed]

    - by Kaidul Islam Sazal
    I am using jquery mobile and I have an array makeArrayin jquery and I have created few listview by the values of the array.Everything works fine.But the jquery mobile list-view style is not shown. Rather it is shown an ordinary list view. This is my code: $(document).ready(function(){ var url = "inventory/inventory.json"; var makeArray = new Array(); $.getJSON(url, function(data){ $.each(data, function(index, item){ if(($.inArray(item.make, makeArray)) == -1){ makeArray.push(item.make); $('.upper_case') .append('<li data-icon="list-arrow"> <a href="trade_form.php?='+ item.make +'"><img src="images/car_logo/buick.png" class="ui-li-thumb"/>' + item.make + '</a></li>'); } }); }); });

    Read the article

  • div in an iframe

    - by Hulk
    In an iframe how to make a div to hide and on mouse over the bottom of the page bring it to front again. This is just like a control that appears in medial players,hide when mouse out and show when mouse over <div> <img src="play.gif"/> <img src="next.gif"/> <img src="last.gif"/> <img src="first.gif"/> <img src="previous.gif"/> <img src="next.gif"/> </div> Thanks..

    Read the article

  • jQuery UI autocomplete not working in IE

    - by Peter Di Cecco
    Hi all, I've got the new autocomplete widget in jQuery UI 1.8rc3 working great in Firefox. It doesn't work at all in IE. Can someone help me out? HTML: <input type="text" id="ctrSearch" size="30"> <input type="hidden" id="ctrId"> Javascript: $("#ctrSearch").autocomplete({ source: "ctrSearch.do", minLength: 3, focus: function(event, ui){ $('#ctrSearch').val(ui.item.ctrLastName + ", " + ui.item.ctrFirstName); return false; }, select: function(event, ui){ $('#ctrId').val(ui.item.ctrId); return false; } }); Result (IE 8): The red box is the <ul> element created by jQuery. I also get this error: Line: 116 Error: Invalid argument. When I open it in the IE8 script debugger, it highlights f[b]=d on line 116 of jquery.min.js. Note that I'm using version 1.4.2 of jQuery hosted on Google's servers (https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js). I've tried removing some of the options, but even when I call .autocomplete() with no options, or with only the source option, I still get the same result. Once again, it's working in Firefox, but not in IE. Any suggestions? Thanks.

    Read the article

  • Get value of multiselect box using jquery or javascript

    - by Hulk
    In the code below, how to get the values of multiselect box in function val() using jquery or javascript. <script> function val() { //Get values of mutliselect drop down box } $(document).ready(function() { var flag=0; $('#emp').change(function() { var sub=$("OPTION:selected", this).val() if(flag == 1) $('#new_row').remove(); $('#topics').val(''); var html='<tr id="new_row" class="new_row"><td>Topics:</td><td> <select id="topic_l" name="topic_l" class="topic_l" multiple="multiple">'; var idarr =new Array(); var valarr =new Array(); {% for top in dict.tops %} idarr.push('{{top.is}}'); valarr.push('{{topic.ele}}'); {% endfor %} for (var i=0;i < idarr.length; i++) { if (sub == idarr[i]) { html += '<option value="'+idarr[i]+'" >'+valarr[i]+'</option>'; } } html +='</select></p></td></tr>'; $('#tops').append(html); flag=1; }); }); </script> Emp:&nbsp;&nbsp;&nbsp;&nbsp;<select id="emp" name="emp"> <option value=""></option> </select> <div name="tops" id="tops"></div> <input type="submit" value="Create Template" id="create" onclick="javascript:var ret=val();return ret;"> Thanks..

    Read the article

  • How to get the child of an element being dragged with jQuery UI

    - by Walden
    I have the following html: <div id="gallery"> <ul> <li> <a href="url I want to get">link</a> </li> </ul> </div> and some jQuery that allows it to be dropped on another div: $trash.droppable({ accept: '#gallery > li', activeClass: 'ui-state-highlight', drop: function(ev, ui) { deleteImage(ui.draggable); var $flickrparenturl = $("a").attr("href"); //only gets href of <li> #1, not <li> being dragged $.post("updateDB.php", { 'flickrparenturl': $flickrparenturl } ); } }); What is the correct way to get the href attribute of the child of the element being dragged? $("a").attr("href"); is only getting the href of the 1st li on the page, not the one being dragged.

    Read the article

  • Traversing from Bookmark Hashtags (#bookmark) in jQuery?

    - by HipHop-opatamus
    I am having trouble traversing from a bookmark has tag in jquery. Specifically, the following HTML: <a id="comment-1"></a> <div class="comment"> <h2 class="title"><a href="#comment-1">1st Post</a></h2> <div class="content"> <p>this is 1st reply to the original post</p> </div> <div class="test">1st post second line</div> </div> I am trying to traverse to where the class = "title", if the page is landed on with a bookmark hashtag in the URL (site.com/test.html#comment-1). The following is my code I'm using for testing: if(window.location.hash) { alert ($(window.location.hash).nextAll().html()); } It executes fine, and returns the appropriate html ( The problem is if I add a selector to it ($(window.location.hash).next('.title').html() ) I get a null result. Why is this so? Is nextAll not the correct Traversing function? (I've also tried next+find to no avail) Thanks!

    Read the article

  • jQuery .attr() crashing Internet Explorer

    - by Sunyatasattva
    Hello everyone, This is my first time posting a question here, as I usually try to find solutions myself. This one, though, being an IE issue, just drives me crazy. I use jQuery cycle plug-in on a website I made and, to populate a caption div, I use a little function that is called after the image is loaded, which uses the "alt" attribute of the image. This seems to exasperate Internet Explorer, which, doesn't have the time to fulfill this apparently so-complicated task, and, as the slideshow cycles, it enters in an infinite loop and eventually crashes – the newer the version, the worse the crash: the older IEs just display an error message saying “The webpage cannot be displayed”, while the newer (7 and 8) completely crash the system. I have no idea on how to solve or work around this. Here is the problematic code. function changeCaption() { var caption = $("img", this).attr("alt"); $('#caption').fadeIn("slow").html(caption); } Thanks in advance for any pointer: I am amazed as how something so simple and globally recognized (didn't encounter any other browser who had problem with this), can cause a problem so big. I also read somewhere that being able to crash a browser remotely is a serious issue :) Lucio

    Read the article

  • using jQuery to load the body of another HTML document between entries

    - by justin hall
    I'm trying to use jQuery to load the body of another HTML document, which contains our AdSense banner. It should display under each blog entry when in list view. I'm able to get it to load text, even images, but not the banner; the banner is a small script. Here is the website we are working with: http://neverknowtech.com/data/ (that's a test page, and the 'entry' displayed there contains the intended body content) As you can see here the body code does include an ad, and the word 'Ad'. The word 'Ad' is shown correctly below the post (as it is in list view) but the script for the Google Ad doesn't seem to make it. Here is what we have in the footer currently (replace [ with < and ] with ): [script type="text/javascript"] var classSelector = ":nth-child(1n)"; if ($(".list-journal-entry-wrapper .journal-entry-wrapper").length ] 0) { $('.list-journal-entry-wrapper .journal-entry-wrapper' + classSelector).after('[div class="journal-list-ad-insert"][/div]'); $('.list-journal-entry-wrapper .journal-list-ad-insert').load("/data/journal-list-ad-insert.html .body"); } [/script] note: the nth-child is there for when they decide how frequently to place the ads.

    Read the article

  • jquery nextUntil has element

    - by Mark
    jquery nextUntil has element I have a bunch of elements like this: <div></div> <span></span> <table></table> <div></div> <span></span> <div></div> I need to check whether or not there's a table element in between the divs, and if so do something. $('div').each(function () { if ($(this).nextUntil('div').include('table')) { $(this).addClass('got-a-table'); } } Something like this? I know that there's no include method, is there something that can get me what I need? Thanks. Result should be like this: <div class='got-a-table'></div> <span></span> <table></table> <div></div> <span></span> <div></div>

    Read the article

  • jquery ajax, array and json

    - by sea_1987
    I am trying to log some input values into an array via jquery and then use those to run a method server side and get the data returned as JSON. The HTML looks like this, <div class="segment"> <div class="label"> <label>Choose region: </label> </div> <div class="column w190"> <div class="segment"> <div class="input"> <input type="checkbox" class="radio" value="Y" name="area[Nationwide]" id="inp_Nationwide"> </div> <div class="label "> <label for="inp_Nationwide">Nationwide</label> </div> <div class="s">&nbsp;</div> </div> </div> <div class="column w190"> <div class="segment"> <div class="input"> <input type="checkbox" class="radio" value="Y" name="area[Lancashire]" id="inp_Lancashire"> </div> <div class="label "> <label for="inp_Lancashire">Lancashire</label> </div> <div class="s">&nbsp;</div> </div> </div> <div class="column w190"> <div class="segment"> <div class="input"> <input type="checkbox" class="radio" value="Y" name="area[West_Yorkshire]" id="inp_West_Yorkshire"> </div> <div class="label "> <label for="inp_West_Yorkshire">West Yorkshire</label> </div> <div class="s">&nbsp;</div> </div> <div class="s">&nbsp;</div> </div> I have this javascript the detect whether the items are checked are not if($('input.radio:checked')){ } What I dont know is how to get the values of the input into an array so I can then send the information through AJAX to my controller. Can anyone help me?

    Read the article

  • Optimizing jQuery for Tabs

    - by jpdbaugh
    I am in the process of developing a widget. The widget has three tabs that are implemented in the following way. <div id="widget"> <ul id="tabs"> <li><a href="http...">One</a></li> <li><a href="http...">Two</a></li> <li><a href="http...">Three</a></li> </ul> <div id="tab_container"> <div id="tab_content"> //Tab Content goes here... </div> </div> </div> // The active class is initialized when the document loads $("#tabs li a").click(function() { $("#tabs li.active").removeClass("active"); $("#tab_content").load($(this).attr('href')); $(this).parent().addClass("active"); return false; }); The problem I am having is that the jquery code that have written is very slow. If the user changes tabs quickly the widget gets behing and bogged down. This causes the tabs to to not align with the data being displayed and just general lag. I believe that this is because the tab is being changed before $.load() is finished. I have tried to implement the following: ("#tabs li a").click(function() { $("#tabs li.active").removeClass("active"); $("#tab_content").load($(this).attr('href'), function (){ $(this).parent().addClass("active"); }); return false; }); It is my understanding that the callback function within in the load function does not execute until the load function is completed. I think this would solve my problem, however I can not come up with a way to select the correct tab that was clicked within the callback function. If this is not the way to do this then what is the best way implement these tabs so that they would stop loading an old request and load the newest tab selection by the user? Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >