Search Results

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

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

  • jQuery Templates - {Supported Tags}

    - by hajan
    I have started with Introduction to jQuery Templates, then jQuery Templates - tmpl(), template() and tmplItem() functions. In this blog we will see what supported tags are available in the jQuery Templates plugin.Template tags can be used inside template together in combination with HTML tags and plain text, which helps to iterate over JSON data. Up to now, there are several supported tags in jQuery Templates plugin: ${expr} or {{= expr}} {{each itemArray}} … {{/each}} {{if condition}} … {{else}} … {{/if}} {{html …}} {{tmpl …}} {{wrap …}} … {{/wrap}}   - ${expr} or {{= expr}} Is used for insertion of data values in the rendered template. It can evaluate fields, functions or expression. Example: <script id="attendeesTemplate" type="text/html">     <li> ${Name} {{= Surname}} </li>         </script> Either ${Name} or {{= Surname}} (with blank space between =<blankspace>Field) will work.   - {{each itemArray}} … {{/each}} each is everywhere the same "(for)each", used to loop over array or collection Example: <script id="attendeesTemplate" type="text/html">     <li>         ${Name} ${Surname}         {{if speaker}}             (<font color="red">speaks</font>)         {{else}}             (attendee)         {{/if}}                 {{each phones}}                             <br />             ${$index}: <em>${$value}</em>         {{/each}}             </li> </script> So, you see we can use ${$index} and ${$value} to get the current index and value while iterating over the item collection. Alternatively, you can add index,value on the following way: {{each(i,v) phones}}     <br />     ${i}: <em>${v}</em> {{/each}} Result would be: Here is complete working example that you can run and see the result: <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server">     <title>Nesting and Looping Example :: jQuery Templates</title>     <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js" type="text/javascript"></script>     <script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js" type="text/javascript"></script>     <script language="javascript" type="text/javascript">         $(function () {             var attendees = [                 { Name: "Hajan", Surname: "Selmani", speaker: true, phones:[070555555, 071888999, 071222333] },                 { Name: "Someone", Surname: "Surname", phones: [070555555, 071222333] },                 { Name: "Third", Surname: "Thirdsurname", phones: [070555555, 071888999, 071222333] },             ];             $("#attendeesTemplate").tmpl(attendees).appendTo("#attendeesList");         });     </script>     <script id="attendeesTemplate" type="text/html">         <li>             ${Name} ${Surname}             {{if speaker}}                 (<font color="red">speaks</font>)             {{else}}                 (attendee)             {{/if}}                     {{each(i,v) phones}}                 <br />                 ${i}: <em>${v}</em>             {{/each}}                 </li>     </script> </head> <body>     <ol id="attendeesList"></ol>     </body> </html>   - {{if condition}} … {{else}} … {{/if}} Standard if/else statement. Of course, you can use it without the {{else}} if you have such condition to check, however closing the {{/if}} tag is required. Example: {{if speaker}}     (<font color="red">speaks</font>) {{else}}     (attendee) {{/if}} You have this same code block in the above complete example showing the 'each' cycle ;).   - {{html …}} Is used for insertion of HTML markup strings in the rendered template. Evaluates the specified field on the current data item, or the specified JavaScript function or expression. Example: - without {{html …}} <script language="javascript" type="text/javascript">   $(function () {   var attendees = [             { Name: "Hajan", Surname: "Selmani", Info: "He <font color='red'>is the speaker of today's</font> session", speaker: true },         ];   $("#myTemplate").tmpl(attendees).appendTo("#speakers"); }); </script> <script id="myTemplate" type="text/html">     ${Name} ${Surname} <br />     ${Info} </script> Result: - with {{html …}} <script language="javascript" type="text/javascript">   $(function () {   var attendees = [             { Name: "Hajan", Surname: "Selmani", Info: "He <font color='red'>is the speaker of today's</font> session", speaker: true },         ];   $("#myTemplate").tmpl(attendees).appendTo("#speakers"); }); </script> <script id="myTemplate" type="text/html">     ${Name} ${Surname} <br />     {{html Info}} </script> Result:   - {{wrap …}} It’s used for composition and incorporation of wrapped HTML. It’s similar to {{tmpl}} Example: <script id="myTmpl" type="text/html">     <div id="personInfo">     <br />     ${Name} ${Surname}     {{wrap "#myWrapper"}}         <h2>${Info}</h2>         <div>             {{if speaker}}                 (speaker)             {{else}}                 (attendee)             {{/if}}         </div>     {{/wrap}}     </div> </script> <script id="myWrapper" type="text/html">     <table><tbody>         <tr>             {{each $item.html("div")}}                 <td>                     {{html $value}}                 </td>             {{/each}}         </tr>     </tbody></table> </script> All the HTMl content inside the {{wrap}} … {{/wrap}} is available to the $item.html(filter, textOnly) method. In our example, we have defined some standard template and created wrapper which calls the other template with id myWrapper. Then using $item.html(“div”) we find the div tag and render the html value (together with the div tag) inside the <td> … </td>. So, here inside td the <div> <speaker or attendee depending of the condition> </div>  will be rendered. The HTML output from this is:   - {{tmpl …}} Used for composition as template items Example: <script id="myTemplate" type="text/html">     <div id="bookItem">         <div id="bookCover">             {{tmpl "#bookCoverTemplate"}}         </div>         <div id="bookDetails">             <div id="book">                             ${title} - ${author}             </div>             <div id="price">$${price}</div>             <div id="Details">${pages} pgs. - ${year} year</div>         </div>     </div> </script> <script id="bookCoverTemplate" type="text/html">     <img src="${image}" alt="${title} Image" /> </script> In this example, using {{tmpl “#bookCoverTemplate”}} I’m calling another template inside the first template. In the other template I’ve created template for a book cover. The rendered HTML of this is: and   So we have seen example for each of the tags that are right now available in the jQuery Templates (beta) plugin which is created by Microsoft as a contribution to the open source jQuery Project. I hope this was useful blog post for you. Regards, HajanNEXT - jQuery Templates with ASP.NET MVC

    Read the article

  • jQuery dialog breaking after closing - I'm using dialog destroy

    - by pedalpete
    I've got a few demo videos I've been making as tutorials, and I'm using a link to open a dialog box and put the demo video in that box. I use the same div to show other notes on the page when a user selects to view a complete note. The code I use to show the notes is jQuery('span.Notes').live('click', function(){ var note=jQuery(this).data('note'); jQuery('div#showNote').text(note); jQuery('div#showNote').append(''); jQuery('div#showNote').dialog({ modal: true, close: function(){ jQuery('div#showNote').dialog('destroy').empty(); } }); }); The code I use for the demo videos is VERY similar. jQuery('a.demoVid').click(function(){ var videoUrl=jQuery(this).attr('href'); jQuery('div#showNote').dialog({ modal: true, height: 400, width: 480, close: function(){ jQuery('div#showNote').dialog('destroy').empty(); } }); swfobject.embedSWF(videoUrl,'showNote','480','390','8.0.0'); return false; }); I can click on as many notes as I want, and the dialog opens up and shows the note. However, when I click the demoVid, the dialog opens, but then closing the dialog kills any other 'showNote' dialogs on the page, so I can't open any more notes, or demo videos.

    Read the article

  • jQuery show submit button on input field click

    - by Pjack
    Hi, I'm trying to have a comment input field that will show the submit button on a dynamically created form when you click on the input field. Similar to how facebook comments work. When you click on the input field the submit button appears and when you click off it disappears. All the comment input id's are comment_1 etc and the submit button id's are submit_1 etc. I've tried this, jQuery("#[id^='comment_']").live('click',function(event){ if(jQuery("#[id^='comment_']").val() == ""){ jQuery("#[id^='submit_']").hide(); } else { jQuery("#[id^='submit_']").show(); } }); And that won't work for some reason. Any suggestion or how it can be accomplished would be great.

    Read the article

  • Looking into the JQuery Image Zoom Plugin

    - by nikolaosk
    I have been using JQuery for a couple of years now and it has helped me to solve many problems on the client side of web development.  You can find all my posts about JQuery in this link. In this post I will be providing you with a hands-on example on the JQuery Image Zoom Plugin.If you want you can have a look at this post, where I describe the JQuery Cycle Plugin.You can find another post of mine talking about the JQuery Carousel Lite Plugin here.I will be writing more posts regarding the most commonly used JQuery Plugins. I have been using extensively this plugin in my websites.You can use this plugin to move mouse around an image and see a zoomed in version of a portion of it. In this hands-on example I will be using Expression Web 4.0.This application is not a free application. You can use any HTML editor you like. You can use Visual Studio 2012 Express edition. You can download it here.  You can download this plugin from this link I launch Expression Web 4.0 and then I type the following HTML markup (I am using HTML 5) <html lang="en">  <head>    <title>Liverpool Legends</title>        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >        <link rel="stylesheet" type="text/css" href="style.css">        <script type="text/javascript" src="jquery-1.8.3.min.js"> </script>     <script type="text/javascript" src="jqzoom.pack.1.0.1.js"></script>        <script type="text/javascript">        $(function () {            $(".nicezoom").jqzoom();        });    </script>       </head>  <body>    <header>        <h1>Liverpool Legends</h1>    </header>        <div id="main">            <a href="championsofeurope-large.jpg" class="nicezoom" title="Champions">        <img src="championsofeurope.jpg"  title="Champions">    </a>          </div>            <footer>        <p>All Rights Reserved</p>      </footer>     </body>  </html>   This is a very simple markup. I have added one large and one small image (make sure you use your own when trying this example) I have added references to the JQuery library (current version is 1.8.3) and the JQuery Image Zoom Plugin. Then I add 2 images in the main div element.Note the class nicezoom inside the href element. The Javascript code that makes it all happen follows.    <script type="text/javascript">        $(function () {            $(".nicezoom").jqzoom();        });    </script>     It couldn't be any simpler than that. I view my simple in Internet Explorer 10 and it works as expected. I have tested this simple solution in all major browsers and it works fine.Inside the head section we can add another Javascript script utilising some more options regarding the zoom plugin.   <script type="text/javascript">            $(function () {        var options = {                  zoomType: 'standard',                  lens:true,                  preloadImages: true,                  alwaysOn:false,                  zoomWidth: 400,                  zoomHeight: 350,                  xOffset:190,                  yOffset:80,                  position:'right'                          };          $('.nicezoom').jqzoom(options);      });         </script> I would like to explain briefly what some of those options mean. zoomType - Other admitted option values are 'reverse','drag','innerzoom' zoomWidth - The popup window width showing the zoomed area zoomHeight - The popup window height showing the zoomed area xOffset - The popup window x offset from the small image.  yOffset - The popup window y offset from the small image.  position - The popup window position.Admitted values:'right' ,'left' ,'top' ,'bottom' preloadImages - if set to true,jqzoom will preload large images. You can test it yourself and see the results in your favorite browser. Hope it helps!!!

    Read the article

  • jquery.ui.draggable.js and jquery.ui.widget.js conflict

    - by Daniel S
    hello I had a working application, which uses a jquery ui dialog. I wanted to make the dialog draggable. As far as I know the only thing needed is the jquery.ui.draggable.js script. So I added it to the scripts I am using, but know I get the following error (as shown in the firebug console): base is not a constructor The relevante line in jquery.ui.widget.js is: var basePrototype = new base(); This is how I am adding all the scripts: <script type="text/javascript" src="/media/development-bundle/jquery-1.4.2.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.core.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.draggable.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.position.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.autocomplete.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.dialog.js"></script> Am I doing something wrong? or is this a problem with jquery? Thanks in advance for any help

    Read the article

  • JQuery Autocomplete plugin not working with JQuery 1.4.1

    - by Russ Clark
    I've been using the JQuery Autocomplete plugin with JQuery version 1.3.2, and it has been working great. I recently updated JQuery in my project to version 1.4.2, and the Autocomplete plugin is now broken. The JQuery code to add items to a textbox on my web page doesn't seem to be getting called at all. Does anyone know if the JQuery Autocomplete plugin is incompatible with JQuery version 1.4.2, and if there is a fix for this problem? Here is some sample code I've built in an ASP.Net web site (which works fine if I change the JQuery file to jquery-1.3.2.js, but nothing happens using jquery-1.4.2.js): <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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 runat="server"> <title>Untitled Page</title> <script type="text/javascript" src="js/jquery-1.4.2.js" ></script> <script type="text/javascript" src="js/jquery.autocomplete.js" ></script> <script type="text/javascript"> $(document).ready(function() { var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" "); $(':input:text:id$=sapleUser').autocomplete(data); }); </script> </head> <body> <form id="form1" runat="server"> API Reference: <input id="sapleUser" autocomplete="off" type="text" runat="server" /> (try "C" or "E") </form> </body> </html>

    Read the article

  • How do I remove descendant elements from a jQuery wrapped set?

    - by Bungle
    I'm a little confused about which jQuery method and/or selectors to use when trying to select an element, and then remove certain descendant elements from the wrapped set. For example, given the following HTML: <div id="article"> <div id="inset"> <ul> <li>This is bullet point #1.</li> <li>This is bullet point #2.</li> <li>This is bullet point #3.</li> </ul> </div> <p>This is the first paragraph of the article</p> <p>This is the second paragraph of the article</p> <p>This is the third paragraph of the article</p> </div> I want to select the article: var $article = $('#article'); but then remove <div id="inset"></div> and its descendants from the wrapped set. I tried the following: var $article = $('#article').not('#inset'); but that didn't work, and in retrospect, I think I can see why. I also tried using remove() unsuccessfully. What would be the correct way to do this? Ultimately, I need to set this up in such a way that I can define a configuration array, such as: var selectors = [ { select: '#article', exclude: ['#inset'] } ]; where select defines a single element that contains text content, and exclude is an optional array that defines one or more selectors to disregard text content from. Given the final wrapped set with the excluded elements removed, I would like to be able to call jQuery's text() method to end up with the following text: This is the first paragraph of the article.This is the second paragraph of the article.This is the third paragraph of the article. The configuration array doesn't need to work exactly like that, but it should provide roughly equivalent configuration potential. Thanks for any help you can provide!

    Read the article

  • Ajax-based data loading using jQuery.load() function in ASP.NET

    - by hajan
    In general, jQuery has made Ajax very easy by providing low-level interface, shorthand methods and helper functions, which all gives us great features of handling Ajax requests in our ASP.NET Webs. The simplest way to load data from the server and place the returned HTML in browser is to use the jQuery.load() function. The very firs time when I started playing with this function, I didn't believe it will work that much easy. What you can do with this method is simply call given url as parameter to the load function and display the content in the selector after which this function is chained. So, to clear up this, let me give you one very simple example: $("#result").load("AjaxPages/Page.html"); As you can see from the above image, after clicking the ‘Load Content’ button which fires the above code, we are making Ajax Get and the Response is the entire page HTML. So, rather than using (old) iframes, you can now use this method to load other html pages inside the page from where the script with load function is called. This method is equivalent to the jQuery Ajax Get method $.get(url, data, function () { }) only that the $.load() is method rather than global function and has an implicit callback function. To provide callback to your load, you can simply add function as second parameter, see example: $("#result").load("AjaxPages/Page.html", function () { alert("Page.html has been loaded successfully!") }); Since load is part of the chain which is follower of the given jQuery Selector where the content should be loaded, it means that the $.load() function won't execute if there is no such selector found within the DOM. Another interesting thing to mention, and maybe you've asked yourself is how we know if GET or POST method type is executed? It's simple, if we provide 'data' as second parameter to the load function, then POST is used, otherwise GET is assumed. POST $("#result").load("AjaxPages/Page.html", { "name": "hajan" }, function () { ////callback function implementation });   GET $("#result").load("AjaxPages/Page.html", function () { ////callback function implementation });   Another important feature that $.load() has ($.get() does not) is loading page fragments. Using jQuery's selector capability, you can do this: $("#result").load("AjaxPages/Page.html #resultTable"); In our Page.html, the content now is: So, after the call, only the table with id resultTable will load in our page.   As you can see, we have loaded only the table with id resultTable (1) inside div with id result (2). This is great feature since we won't need to filter the returned HTML content again in our callback function on the master page from where we have called $.load() function. Besides the fact that you can simply call static HTML pages, you can also use this function to load dynamic ASPX pages or ASP.NET ASHX Handlers . Lets say we have another page (ASPX) in our AjaxPages folder with name GetProducts.aspx. This page has repeater control (or anything you want to bind dynamic server-side content) that displays set of data in it. Now, I want to filter the data in the repeater based on the Query String parameter provided when calling that page. For example, if I call the page using GetProducts.aspx?category=computers, it will load only computers… so, this will filter the products automatically by given category. The example ASPX code of GetProducts.aspx page is: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetProducts.aspx.cs" Inherits="WebApplication1.AjaxPages.GetProducts" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table id="tableProducts"> <asp:Repeater ID="rptProducts" runat="server"> <HeaderTemplate> <tr> <th>Product</th> <th>Price</th> <th>Category</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <%# Eval("ProductName")%> </td> <td> <%# Eval("Price") %> </td> <td> <%# Eval("Category") %> </td> </tr> </ItemTemplate> </asp:Repeater> </ul> </div> </form> </body> </html> The C# code-behind sample code is: public partial class GetProducts : System.Web.UI.Page { public List<Product> products; protected override void OnInit(EventArgs e) { LoadSampleProductsData(); //load sample data base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.Count > 0) { if (!string.IsNullOrEmpty(Request.QueryString["category"])) { string category = Request.QueryString["category"]; //get query string into string variable //filter products sample data by category using LINQ //and add the collection as data source to the repeater rptProducts.DataSource = products.Where(x => x.Category == category); rptProducts.DataBind(); //bind repeater } } } //load sample data method public void LoadSampleProductsData() { products = new List<Product>(); products.Add(new Product() { Category = "computers", Price = 200, ProductName = "Dell PC" }); products.Add(new Product() { Category = "shoes", Price = 90, ProductName = "Nike" }); products.Add(new Product() { Category = "shoes", Price = 66, ProductName = "Adidas" }); products.Add(new Product() { Category = "computers", Price = 210, ProductName = "HP PC" }); products.Add(new Product() { Category = "shoes", Price = 85, ProductName = "Puma" }); } } //sample Product class public class Product { public string ProductName { get; set; } public decimal Price { get; set; } public string Category { get; set; } } Mainly, I just have sample data loading function, Product class and depending of the query string, I am filtering the products list using LINQ Where statement. If we run this page without query string, it will show no data. If we call the page with category query string, it will filter automatically. Example: /AjaxPages/GetProducts.aspx?category=shoes The result will be: or if we use category=computers, like this /AjaxPages/GetProducts.aspx?category=computers, the result will be: So, now using jQuery.load() function, we can call this page with provided query string parameter and load appropriate content… The ASPX code in our Default.aspx page, which will call the AjaxPages/GetProducts.aspx page using jQuery.load() function is: <asp:RadioButtonList ID="rblProductCategory" runat="server"> <asp:ListItem Text="Shoes" Value="shoes" Selected="True" /> <asp:ListItem Text="Computers" Value="computers" /> </asp:RadioButtonList> <asp:Button ID="btnLoadProducts" runat="server" Text="Load Products" /> <!-- Here we will load the products, based on the radio button selection--> <div id="products"></div> </form> The jQuery code: $("#<%= btnLoadProducts.ClientID %>").click(function (event) { event.preventDefault(); //preventing button's default behavior var selectedRadioButton = $("#<%= rblProductCategory.ClientID %> input:checked").val(); //call GetProducts.aspx with the category query string for the selected category in radio button list //filter and get only the #tableProducts content inside #products div $("#products").load("AjaxPages/GetProducts.aspx?category=" + selectedRadioButton + " #tableProducts"); }); The end result: You can download the code sample from here. You can read more about jQuery.load() function here. I hope this was useful blog post for you. Please do let me know your feedback. Best Regards, Hajan

    Read the article

  • Using JavaScript/jQuery to return a list of CSS selectors based on highlighted text

    - by Bungle
    I've been given some project requirements that involve (ideally) returning a list of CSS selectors based on highlighted text. In other words, a user could do something like this on a page: Click a button to indicate that their next text selection should be recorded. Highlight some text on the page. See a generated list of CSS selectors that correspond to all the elements that contain the highlighted text. Firstly, does this seem like a feasible goal? jQuery makes it easy to use a selector to access a particular element, but I'm not sure if the reverse holds true. If an element lacks an id attribute, I also don't know how you'd return an "optimized" selector - i.e., one that identifies an element uniquely. Maybe crawl up the DOM until you find an ID, then stem the selector from there? Secondly, from a high-level perspective, any ideas on how to go about this? Any tips or tricks that could speed development? I very much appreciate any help. Thanks!

    Read the article

  • Looking into the JQuery Carousel Lite Plugin

    - by nikolaosk
    I have been using JQuery for a couple of years now and it has helped me to solve many problems on the client side of web development. You can find all my posts about JQuery in this link. In this post I will be providing you with a hands-on example on the JQuery Carousel Lite Plugin.If you want you can have a look at this post, where I describe the JQuery Cycle Plugin. I will be writing more posts regarding the most commonly used JQuery Plugins. I have been using extensively this plugin in my websites.You can show a portion of a set of images with previous and next navigation.In this hands-on example I will be using Expression Web 4.0.This application is not a free application. You can use any HTML editor you like.You can use Visual Studio 2012 Express edition. You can download it here. You can download this plugin from this linkI launch Expression Web 4.0 and then I type the following HTML markup (I am using HTML 5)<html lang="en">  <head>    <title>Liverpool Legends</title>        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >        <link rel="stylesheet" type="text/css" href="style.css">        <script type="text/javascript" src="jquery-1.8.3.min.js"> </script>     <script type="text/javascript" src="jcarousellite_1.0.1.min.js"></script>      <script type="text/javascript">        $(function () {            $(".theImages").jCarouselLite({                btnNext: "#Nextbtn",                btnPrev: "#Previousbtn"            });        });    </script>       </head>  <body>    <header>        <h1>Liverpool Legends</h1>    </header>        <div id="main">           <img id="Previousbtn" src="previous.png" />        <div class="theImages">            <ul>                <li><img src="championsofeurope.jpg"></li>                <li><img src="steven_gerrard.jpg"></li>                <li><img src="ynwa.jpg"></li>                <li><img src="dalglish.jpg"></li>                <li><img src="Souness.jpg"></li>                  </ul>    </div>    <img id="Nextbtn" src="next.png" />          </div>            <footer>        <p>All Rights Reserved</p>      </footer>     </body>  </html>  This is a very simple markup. I have added my photos (make sure you use your own when trying this example)I have added references to the JQuery library (current version is 1.8.3) and the JQuery Carousel Lite Plugin. Then I add 5 images in the theImages div element.The Javascript code that makes it all happen follows.  <script type="text/javascript">        $(function () {            $(".theImages").jCarouselLite({                btnNext: "#Nextbtn",                btnPrev: "#Previousbtn"            });        });    </script>I also have added some basic CSS style rules in the style.css file. body{background-color:#efefef;color:#791d22;}       #Previousbtn{position:absolute; left:5px; top:100px;}#Nextbtn {position:absolute; left:812px; top:100px;}.theImages {margin-left:145px;margin-top:10px;} It couldn't be any simpler than that. I view my simple in Internet Explorer 10 and it works as expected.I have tested this simple solution in all major browsers and it works fine.Hope it helps!!!

    Read the article

  • Looking into the JQuery Cycle Plugin

    - by nikolaosk
    I have been using JQuery for a couple of years now and it has helped me to solve many problems on the client. You can find all my posts about JQuery in this link. In this post I will be providing you with a hands-on example on the JQuery Cycle Plugin.I have been using extensively this plugin in my websites.You can rotate a series of images using various transitions with this plugin.It is a slideshow type of experience. I will be writing more posts regarding the most commonly used JQuery Plugins.  In this hands-on example I will be using Expression Web 4.0.This application is not a free application. You can use any HTML editor you like.You can use Visual Studio 2012 Express edition. You can download it here.  You can download this plugin from this link I launch Expression Web 4.0 and then I type the following HTML markup (I am using HTML 5) <!DOCTYPE html><html lang="en">  <head>    <title>Liverpool Legends</title>        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >            <script type="text/javascript" src="jquery-1.8.3.min.js"> </script>     <script type="text/javascript" src="jquery.cycle.all.js"></script>              <script type="text/javascript">        $(function() {            $('#main').cycle({ fx: 'fade'});        });    </script>       </head>  <body>    <header>        <h1>Liverpool Legends</h1>    </header>        <div id="main">                   <img src="championsofeurope.jpg" alt="Champions of Europe">                        <img src="steven_gerrard.jpg" alt="Steven Gerrard">                        <img src="ynwa.jpg" alt="You will never walk alone">                       </div>            <footer>        <p>All Rights Reserved</p>      </footer>     </body>  </html> This is a very simple markup. I have added three photos (make sure you use your own when trying this example)I have added references to the JQuery library (current version is 1.8.3) and the JQuery Cycle Plugin. Then I have added 3 images in the main div element.The Javascript code that makes it all happen follows.  <script type="text/javascript">        $(function() {            $('#main').cycle({ fx: 'fade'});        });    </script>  It couldn't be any simpler than that. I view my simple in Internet Explorer 10 and it works as expected. I have this series of images transitioning one after the other using the "fade" effect. I have tested this simple solution in all major browsers and it works fine.We can have a different transition effect by changing the JS code. Have a look at the code below       <script type="text/javascript">        $(function() {            $('#main').cycle({                     fx: 'cover',        speed: 500,        timeout: 2000                        });        });    </script>   We set the speed to 500 milliseconds, that is the speed we want to have for the ‘cover’ transition.The timeout is set to two seconds which is the time the photo will show until the next transition will take place.We can customise this plugin further but this is a short introduction to the plugin.Hope it helps!!!

    Read the article

  • What is the "standard" JQuery treeview that most people use? It seems the most popular plugin isn't

    - by Pete Alvin
    I've chosen JQuery as my JavaScript library but now I'm a bit frustrated by the JQuery plugin site... the site kinda sucks... the plugin area isn't designed very well and I can only find a few treeviews. The one with the most votes (link text) isn't supported anymore. Can someone please point me to an industrial strength treeview? Desired Features: 1. stable 2. async / ajax would be nice 3. drag and drop nodes would be nice I've been delighted so far with JQueryUI--nice design. But, how come it doesn't come with a standard tree view? Pete

    Read the article

  • jQuery scrollTop not working in chrome but working in Firefox

    - by Maju
    I have used a scrollTop function in jquery for navigating to top. But strangely 'The smooth animated scroll' stopped working in safari and chrome(scrolling without smooth animation) after I made some changes. But it is working smoothly in Firefox. What could be wrong? Here is the jquery function i used, jQuery $('a#gotop').click(function() { $("html").animate({ scrollTop: 0 }, "slow"); //alert('Animation complete.'); //return false; }); HTML <a id="gotop" href="#">Go Top </a> CSS #gotop { Cursor: pointer; position: relative; float:right; right:20px; /*top:0px;*/ }

    Read the article

  • Jquery Accordion and Fading

    - by Slick Willis
    I am trying to create a jquery accordion that fades the header of the accordion out when the page is loaded then fades it in when the mouse hovers. The accordion also opens when the mouse hovers. I am able to get all of this working, the problem I am having is when the accordion opens the header moves away and the mouse is no longer on it to keep it lit. I would like the links to keep the header lit as well as if the mouse is on the header itself. Below is the code that I wrote for it. <html> <head <script type='text/javascript' src='http://accidentalwords.squarespace.com/storage/jquery/jquery-1.4.2.min.js'></script> <script type='text/javascript' src='http://accidentalwords.squarespace.com/storage/jquery/jquery-custom-181/jquery-ui-1.8.1.custom.min.js'></script> </head> <body bgcolor="black"> <style = "css/text"> .links { font-family: "Georgia", "Verdana", serif; line-height: 30px; margin-left: 20px; margin-top: 5px; } .Title { font-family: "Geneva", "Verdana", serif; font-weight: bold; font-size: 2em; text-align: left; font-variant: small-caps; border-bottom: solid 2px #25FF00; padding-bottom:5px; margin-bottom: 10px; } </style> <script type="text/javascript"> $(document).ready(function(){ $(".Title").fadeTo(1,0.25); $(".Title").hover(function () { $(this).stop().fadeTo(250,1) .closest(".Title").find(".links").fadeTo(250,0.75); }, function() { $(this).stop().fadeTo(250,0.25); }); }); $(function() { $("#accordion").accordion({ event: "mouseover" }); }); </script> <p>&nbsp</p> <div id="accordion"> <div class="Title"><a href="#"STYLE="TEXT-DECORATION: NONE; color: #25FF00;">Reference</a></div> <div class="links"> <a href="http://docs.jquery.com/Main_Page" STYLE="TEXT-DECORATION: NONE; color: #25FF00;">Jquery Documentation/Help</a><br> <a href="http://stackoverflow.com/" STYLE="TEXT-DECORATION: NONE; color: #25FF00;">Stack Overflow</a><br> <a href="http://www.w3schools.com/" STYLE="TEXT-DECORATION: NONE; color: #25FF00;">w3schools.com</a><br> </div> <div class="Title"><a href="#"STYLE="TEXT-DECORATION: NONE; color: #FF7200;">Gaming</a></div> <div class="links"> <a href="http://docs.jquery.com/Main_Page" STYLE="TEXT-DECORATION: NONE; color: #FF7200;">Jquery Documentation/Help</a><br> <a href="http://stackoverflow.com/" STYLE="TEXT-DECORATION: NONE; color: #FF7200;">Stack Overflow</a><br> <a href="http://www.w3schools.com/" STYLE="TEXT-DECORATION: NONE; color: #FF7200;">w3schools.com</a><br></div> <div class="Title"><a href="#"STYLE="TEXT-DECORATION: NONE; color: #00DEFF;">Grub</a></div> <div class="links"> <a href="http://docs.jquery.com/Main_Page" STYLE="TEXT-DECORATION: NONE; color: #00DEFF;">Jquery Documentation/Help</a><br> <a href="http://stackoverflow.com/" STYLE="TEXT-DECORATION: NONE; color: #00DEFF;">Stack Overflow</a><br> <a href="http://www.w3schools.com/" STYLE="TEXT-DECORATION: NONE; color: #00DEFF;">w3schools.com</a><br> </div> <div class="Title"><a href="#"STYLE="TEXT-DECORATION: NONE; color: #F8FF00;">Drinks</a></div> <div class="links"> <a href="http://docs.jquery.com/Main_Page" STYLE="TEXT-DECORATION: NONE; color: #F9FF00;">Jquery Documentation/Help</a><br> <a href="http://stackoverflow.com/" STYLE="TEXT-DECORATION: NONE; color: #F8FF00;">Stack Overflow</a><br> <a href="http://www.w3schools.com/" STYLE="TEXT-DECORATION: NONE; color: #F8FF00;">w3schools.com</a><br> </div> </div> </body> </html>

    Read the article

  • JQuery: combine two jq selectors

    - by Bruno
    Hi there. Im sure the solution is simple but I cant figure it out :( I need to combine two jquery selectors in one selector: $(this) + $('input[type=text]:first') $(this) is e.g div#selected so the result should be: $('div#selected input[type=text]:first').focus(); How to do?

    Read the article

  • jQuery multiple selectors into dynamic attribute

    - by Jason Fletcher
    I am trying to attach an event to a separate onhover trigger. But I am having problems using multiple selectors since its dynamic. Need help ::: Upon hovering on the yellow box named 'Rings', this should trigger the animated slide event for the green box above it. http://home.jasonfletcher.info/all/alliteration/index.html $('.boxgrid1').hover(function(){ $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300}); }, function() { $(".cover", this).stop().animate({top:'247px'},{queue:false,duration:300}); });

    Read the article

  • jQuery: Can't get tooltip plugin to work

    - by Rosarch
    I'm trying to use this tooltip plugin: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/. I can't seem to get it to work. <head> <script type="text/javascript" src="/static/JQuery.js"></script> <script type="text/javascript" src="/static/jquery-ui-1.8.1.custom.min.js"></script> <script type="text/javascript" src="/static/jquery.json-2.2.min.js"></script> <script type="text/javascript" src="/static/jquery.form.js"></script> <script type="text/javascript" src="/static/js-lib/jquery.bgiframe.js"></script> <script type="text/javascript" src="/static/js-lib/jquery.delegate.js"></script> <script type="text/javascript" src="/static/js-lib/jquery.dimensions.js"></script> <script type="text/javascript" src="/static/jquery.tooltip.js"></script> <script type="text/javascript" src="/static/sprintf.js"></script> <script type="text/javascript" src="/static/clientside.js"></script> </head> I try it out in a simple example: clientside.js: $(document).ready(function () { $("#set1 *").tooltip(); }); The target html: <div id="set1"> <p id="welcome">Welcome. What is your email?</p> <form id="form-username-form" action="api/user_of_email" method="get"> <p> <label for="form-username">Email:</label> <input type="text" name="email" id="form-username" /> <input type="submit" value="Submit" id="form-submit" /> </p> </form> <p id="msg-user-accepted"></p> </div> Unfortunately, nothing happens. What am I doing wrong?

    Read the article

  • Using jQuery Live instead of jQuery Hover function

    - by hajan
    Let’s say we have a case where we need to create mouseover / mouseout functionality for a list which will be dynamically filled with data on client-side. We can use jQuery hover function, which handles the mouseover and mouseout events with two functions. See the following example: <!DOCTYPE html> <html lang="en"> <head id="Head1" runat="server">     <title>jQuery Mouseover / Mouseout Demo</title>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>     <style type="text/css">         .hover { color:Red; cursor:pointer;}     </style>     <script type="text/javascript">         $(function () {             $("li").hover(               function () {                   $(this).addClass("hover");               },               function () {                   $(this).removeClass("hover");               });         });     </script> </head> <body>     <form id="form2" runat="server">     <ul>         <li>Data 1</li>         <li>Data 2</li>         <li>Data 3</li>         <li>Data 4</li>         <li>Data 5</li>         <li>Data 6</li>     </ul>     </form> </body> </html> Now, if you have situation where you want to add new data dynamically... Lets say you have a button to add new item in the list. Add the following code right bellow the </ul> tag <input type="text" id="txtItem" /> <input type="button" id="addNewItem" value="Add New Item" /> And add the following button click functionality: //button add new item functionality $("#addNewItem").click(function (event) {     event.preventDefault();     $("<li>" + $("#txtItem").val() + "</li>").appendTo("ul"); }); The mouse over effect won't work for the newly added items. Therefore, we need to use live or delegate function. These both do the same job. The main difference is that for some cases delegate is considered a bit faster, and can be used in chaining. In our case, we can use both. I will use live function. $("li").live("mouseover mouseout",   function (event) {       if (event.type == "mouseover") $(this).addClass("hover");       else $(this).removeClass("hover");   }); The complete code is: <!DOCTYPE html> <html lang="en"> <head id="Head1" runat="server">     <title>jQuery Mouseover / Mouseout Demo</title>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>     <style type="text/css">         .hover { color:Red; cursor:pointer;}     </style>     <script type="text/javascript">         $(function () {             $("li").live("mouseover mouseout",               function (event) {                   if (event.type == "mouseover") $(this).addClass("hover");                   else $(this).removeClass("hover");               });             //button add new item functionality             $("#addNewItem").click(function (event) {                 event.preventDefault();                 $("<li>" + $("#txtItem").val() + "</li>").appendTo("ul");             });         });     </script> </head> <body>     <form id="form2" runat="server">     <ul>         <li>Data 1</li>         <li>Data 2</li>         <li>Data 3</li>         <li>Data 4</li>         <li>Data 5</li>         <li>Data 6</li>     </ul>          <input type="text" id="txtItem" />     <input type="button" id="addNewItem" value="Add New Item" />     </form> </body> </html> So, basically when replacing hover with live, you see we use the mouseover and mouseout names for both events. Check the working demo which is available HERE. Hope this was useful blog for you. Hope it’s helpful. HajanReference blog: http://codeasp.net/blogs/hajan/microsoft-net/1260/using-jquery-live-instead-of-jquery-hover-function

    Read the article

  • useFastClick in JQuery Mobile

    - by Yousef_Jadallah
      Normal 0 false false false EN-US X-NONE AR-SA /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;} For who want to convert the application from JQM Alpha to JQM Beta 1, needs to bind  click  events to the new vclick one. Click event is working in general browsers butt that is needed for iOS and Android, useFastClick  is (touch + mouse click). Moreover if you have this event alot in your project you can turn useFastClick off in mobileinit event: $(document).bind("mobileinit", function () {             $.mobile.useFastClick = false; });   vclick event is needed to support touch events to make the page changes to happen faster, and to perform the URL hiding. So you need to change something like this  $('btnShow').live("click", function (evt) {   To :  $('btnShow').live("vclick", function (evt) {     For more information : http://jquerymobile.com/test/docs/api/globalconfig.html   Here you can find full example in this case : <!DOCTYPE ><html xmlns="http://www.w3.org/1999/xhtml"><head>    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />    <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>    <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>    <script type="text/javascript">     //Here you need to use vclick instead of click event         $('ul[id="MylistView"] a').live("vclick", function (evt) {            alert('list click');        });      </script>    <title></title></head><body>    <div id="FirstPage" data-role="page" data-theme="b">        <div data-role="header">            <h1>                Page Title</h1>        </div>        <div data-role="content">            <ul id="MylistView" data-role="listview" data-theme="g">                <li><a href="#SecondPage">Acura</a></li>                <li><a href="#SecondPage">Audi</a></li>                <li><a href="#SecondPage">BMW</a></li>            </ul>        </div>        <div data-role="footer">            <h4>                Page Footer</h4>        </div>    </div>    <div id="SecondPage" data-role="page" data-theme="b"   >        <div data-role="header" >            <h1>                Page Title</h1>        </div>        Second Page        <div data-role="footer">            <h4>                Page Footer</h4>        </div>    </div></body></html>     Hope that helps.

    Read the article

  • jQuery selectors - parental problems

    - by aressidi
    Hi there, I have an emote selector that opens up when a user clicks an entry in a diary. The way I've worked it is that the emote selector panel lives hidden at the top of the page. When a user clicks on the 'emote control' associated with an entry, I use JavaScript to grab the HTML of the emote selector panel from the top of the page and insert it next to the entry. Using Firebug, here's what the finished product would look like in the page (snippet from element inspect). I'm trying to get the ID for the class 'emote-control-container' which contains the entry id: <td> <div id="1467002" class="emote-select emote-default">&nbsp;</div> <div class="emote-control-container" id="emote-controls-1467002"> <div id="emote-control-selector"> <div id="emote-control-selector-body"> <ul> <li id="emote-1"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li> <li id="emote-2"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li> <li id="emote-3"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li> <li id="emote-4"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li> </ul> </div> <div id="emote-control-selector-footer"> &nbsp; </div> </div> </div> </td> I need the entry ID along with the emote ID to make a post via AJAX when a user selects an emote from the selector panel by clicking on it. I'm able to get the emote ID just fine with this, which I'm using to alert-out the selected emote ID: jQuery('li').live('click', function(e) { e.preventDefault; var emoteId = this.id; alert(emoteId); }); I'm having trouble traversing up DOM to get the element ID from '.emote-control-container. I've tried everything, but I'd expect this to work, but it doesn't: jQuery('li').live('click', function(e) { e.preventDefault; var entryId = jQuery(this.id).parent(".emote-control-container").attr("id"); alert(entryId); }); What am I doing wrong.? I can't target the ID of the .emote-control-container.

    Read the article

  • Get reference to all instances of jquery ui widget?

    - by Hailwood
    I am writing a jquery UI widget that simply wraps the bootstrap popover plugin, In the widget you can pass in the option 'singular', if this is passed in then it should call a function of all other instances of the plugin. something like $('#one').myWidget(); $('#two').myWidget(); $('#three').myWidget(); $('#four').myWidget(); $('#one').myWidget('show'); //stuff from widget one is now visible $('#two').myWidget('show'); //stuff from widget one and two are now visible $('#three').myWidget('show'); //stuff from widget one, two and three are now visible $('#two').myWidget('hide'); //stuff from widget one and three are now visible $('#four').myWidget('show', {singular:true}); //stuff from widget four is now visible So, I imagine the show function looking like: show: function(options){ options = options || {}; if(options.singular){ var instances = '????'; // how do I get all instances? $.each(instances, function(i, o){ o.myWidget('hide'); }); } this.element.popover('show'); } So, question being, how would I get a reference to all elements that have the myWidget widget on them?

    Read the article

  • jQuery selectors with meta-characters

    - by steamboy
    Hello Guys, I'm having problem selecting an element with an id like this <li ="0f:Bactidol_Recorder.mp4">. I tried using the function that escapes meta-characters with two backslashes below from this jquery link but still can't select the element Function: function jq(myid) { return '#' + myid.replace(/(:|\.)/g,'\\$1'); } Example: $(jq('0fb:Bactidol_Recorder.mp4')).empty() Output: $(#0fb\\:Bactidol_Recorder\\.mp4).empty();

    Read the article

  • jQuery Selectors: how to access an a tag, whose span has a specific class?

    - by Paul
    I'm messing around with FullCalendar jQuery calendar, and qTips, so that I can display more information about the event upon mouseover. I've added a summary element to the FullCalendar js, and also my server code. I then added a new qTip in the eventMouseover method, based on the span class, which works prefectly. However, if the event stretches over a couple of days, the qTip only works (because it is a span tag), on the text itself, not the entire blue strip. What I want to do is to assign the qTip to the a tag, and make the a tags display block. This works currently: eventMouseover: function(event){ $('span[class=fc-event-title]').each(function() { if( $(this).text() == event.title ) { $(this).qtip({ content: event.summary, style: { border: { width: 1, radius: 5, color: '#6699CC' }, width: 200 } }); } }); but I can't figure out how to select the a tag where it contains a span with class of fc-event-title. Many thanks for any assistance.

    Read the article

  • Getting value from href using jQuery

    - by bateman_ap
    Hi, I wonder if anyone can help with a jQuery problem I am having. I am using the tooltips from the Jquery Tools library to create a popup window when mousing over an hrefed image, this I want to use to cusomise the call to change the content in the DIV. The links I am using are in the form: <a href="/venue/1313.htm" class="quickView"><img src="/images/site/quickView83.png" alt="Quick View" width="83" height="20" /></a> The code I am using to trigger the tip is: $(".quickView").live('mouseover', function() { if (!$(this).data('init')) { $(this).data('init', true); ajax_quickView(); $(this).tooltip ({ /* tooltip configuration goes here */ tip: "#quickViewWindow", position: "right", offset: [0, -300], effect: 'slide' }); $(this).trigger('mouseover'); } }); I have tried the following function to grab the ID (in the example above, 1313) from the link: function ajax_quickView(){ var pageNum = $("a.quickView").attr("href").match(/venue/([0-9]+)/).htm[1]; $("#quickViewWindow").load("/quick-view/", function(){}) } However I think this is where it falls down, I think my regex is prob to blame... Once I get the var pageNum I presume I can just pass it into the .load as: $("#quickViewWindow").load("/quick-view/", {id : pageNum }, function(){}) Many thanks

    Read the article

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