Search Results

Search found 753 results on 31 pages for 'selectors'.

Page 16/31 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Selecting multiple cached elements

    - by Globalz
    In jQuery you can select two elements by id like: $('#elem, #elem2'); BUT What if you have cached the elem and elem2, and what to apply the same method/function to them both? i.e. $elem = $('#elem'); $elem2 = $('#elem2'); This obviously wont work: $($elem, $elem2) Thanks!

    Read the article

  • Adding watermarks to textarea

    - by Hulk
    How to add watermarks like "Enter textarea" for a textarea. <textarea rows = "8" cols = "18" border ="0" class="input" style="border: none;" WRAP id="details" name ="details"></textarea> Thanks..

    Read the article

  • 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

  • scroll bar in textareas

    - by Hulk
    Int the following code, The scroll bar appears in IE and in mozilla it doesnt,how is this to be fixed,scroll bar should not appear where there is not much of data. <script> var row= '<table><tr>'; row = '<tr class="display_row"">'; row += '<td class="display_col" wrap width="75"><b><textarea rows = "8" cols = "18" border ="1" class="input" style="border: none;overflow:visible;width:95%;" readonly maxlength="5">Name selected is Tom </textarea>'; row+='</td></tr></table>'; </script>

    Read the article

  • jquery parent/children selector for counting <li>

    - by Kreker
    Hi. I have this piece of HTML <div id="fileTreeInviati"> <ul class="php-file-tree"> <li class="pft-directory"> <a href="#" class="" name="101">A006 - SOMETEXT (<span name="contaNew"></span>)</a> <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/> <ul style="display: none;"> <li class="pft-file ext-png"> <a href="javascript:getInfoFile('4');" class="" id="4">cut.png</a> </li> <li class="pft-file ext-dll"> <a href="javascript:getInfoFile('27');" class="new" id="27">Safari.dll</a> </li> </ul> </li> <li class="pft-directory"> <a href="#" class="" name="102">A012 - SOMETEXT (<span name="contaNew"></span>)</a> <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/> <ul style="display: none;"> <li class="pft-file ext-jpg"> <a href="javascript:getInfoFile('19');" class="new" id="19">04.jpg</a> </li> <li class="pft-file ext-dll"> <a href="javascript:getInfoFile('24');" class="new" id="24">Safari.dll</a> </li> </ul> </li> <li class="pft-directory"> <a href="#" class="" name="103">A014 - SOMETEXT (<span name="contaNew"></span>)</a> <img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/> <ul style="display: none;"> <li class="pft-file ext-txt"> <a href="javascript:getInfoFile('17');" class="new" id="17">acu.txt</a> </li> <li class="pft-file ext-dll"> <a href="javascript:getInfoFile('22');" class="new" id="22">Safari.dll</a> </li> </ul> </li> </ul> I'm working on a js snippet that cycle through all "a" of the "li" and checks if it has the class "new" if yes increment a counter by one. This counter now has to be printed on the relative "li" "span" 3 level before. So I have the number of the element with the "new" class. The js snippet is this $("#fileTreeInviati .php-file-tree .pft-directory li").each(function(){ $(this).children("a").each(function(i,e){ if ($(e).hasClass("new")){ cont++; console.log($(e).text()); $(this).parent().parent().parent().children("a").children("span").text(cont); } }) cont = 0; }); I think I'm almost there but the counter is always 1. I think there is something mess with .children, maybe it can handle only the first occurrence? Thanks for help

    Read the article

  • jQuery - search for previous selector relative to current

    - by Thomas Slater
    I have a form with 3 sections in it. Each section has a dedicated div for fairly long contextual help messages regarding the input that has focus. My question is, if I give each of these help divs a class of "form-tip" and each input that has a tip the class "has-tip", how can I get the tip to always show up in the previous "form-tip" div? Something like: $('.has-tip').each(focus(function() { var tip = $(this).attr('title'); // Find most recent $('.form-tip') in the DOM and populate it with tip })); I hope that makes sense... Thanks for any help.

    Read the article

  • Jquery click event

    - by ram
    This is my code $(document).ready(function () { $("#Button1").click(showDialog); }); var showDialog = function () { /* Something I do here */ } Here the "Button1" click event fire at first time, after that the event was not firing. Thanks, Ram

    Read the article

  • Comparing 2 tables column values and copying the next column content to the second table

    - by Sullan
    Hi All.. I am comparing between two tables first column each. If there is find a match i am copying the text from the adjacent cell of the first table to the second table. I am able to compare strings and get the value, but finding it difficult to print it in the second table. I am getting the value in the var "replaceText", but how to print it in the second table ?? Please help... Sample code is as follows.. <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function(){ jQuery('.itemname').each(function(){ var itemName = jQuery(this).text(); jQuery('.comparerow').each(function() { var compareRow = jQuery(this).text(); if (itemName == compareRow) { var replaceText = jQuery(this).next('td').text(); alert(replaceText); } }); }); }); </script> HTML is as follows <table width="100%"><thead> <tr> <th align="left" >Name</th><th>Description</th></tr></thead> <tbody> <tr> <td class="comparerow">IX0001</td> <td class="desc">Desc 1 </td> </tr> <tr> <td class="comparerow">IX0002</td> <td class="desc" >Desc 2 </td> </tr> <tr> <td class="comparerow">IX0003</td> <td class="desc">Desc 3 </td> </tr> <tr> <td class="comparerow">IX0004</td> <td class="desc">Desc 4 </td> </tr> </tbody> </table> <br /> <table width="100%"> <tr> <th>Name</th><th>Description</th> </tr> <tr > <td class="itemname">IX0001</td><td></td> </tr> <tr> <td class="itemname">IX0002</td><td></td> </tr> <tr> <td class="itemname">IX0003</td><td></td> </tr> </table>

    Read the article

  • How to get the text of a div which is not a part of any other container in JQuery?

    - by Raja
    This should be real easy. Given below is the HTML. <div id='attachmentContainer'> #Attachment# <span id='spnAttachmentName' class='hidden'>#AttachmentName#</span> <span id='spnAttachmentPath' class='hidden'>#AttachmentPath#</span> </div> I want to get just the #Attachment# and not the other text. When I tried $("#attachmentContainer").text() it gives out all #Attachment#, #AttachmentName# as well as #AttachmentPath#. I know I could just put #Attachment# into another span and access it directly but I was just intrigued on how to do this. Any help is much appreciated.

    Read the article

  • Highlighting text beween custom tags

    - by Rachel
    In a xhtml, i want to highlight the text between two self closing tags s1 and s2 whose attribute value is the same. Eg. <s1 ind="1"/> and <s2 ind="1" /> Eg. <html> <body> <a> <b>Some <s1 ind="1"/> text</b> <c>data <s2 ind="1"/>here</c> </a> </body> </html> I want "text data" to get highlighted. Is is possible to achieve using javascript/jquery? I could have many such self closing tag pairs s1 and s2 with a unique value for "ind" for the pair indicating that the text within them needs to be highlighted.

    Read the article

  • Generating thumbnails using jquery or javascript

    - by Hulk
    All, Can any 1 of you show a small piece of code for generating a thumbnail of any website using javascript or jquery, I had posted earlier but couldnt find any right match for my requirements. <div id="generate_thumbnail" onclick ="generate();"> //Show thumbnail within this div </div> <Script> function generate() { // generate small thumbnail }

    Read the article

  • jQuery - get a list of values of an attribute from elements of a class

    - by Ankur
    I have a class called object which has an element called 'level'. I want to get a list of all the different values of level on the page so I can select the highest one. If I do something like: $(".object").attr("level") will that get me a list of values that are the values of the level attribute? I suspect not, but then how do you do something like that. Note: I don't want to select an HTML object for manipulation as is more common, rather I want to select values of the attribute.

    Read the article

  • jQuery selector loads images from server

    - by Guillaume
    Hi! here is the code: <script type="text/javascript"> var ajax_data = '<ul id="b-cmu-rgt-list-videos"><li><a href="{video.url}" '+ 'title="{video.title.strip}"><img src="{video.image}" '+ 'alt="{video.title.strip}" /><span>{video.title}</span></a></li></ul>'; var my_img = $(ajax_data).find('img'); </script>` ajax_data is data from a JS template engine where I need to get some part of it. The problem is that jQuery does a GET on the img src={video.image}: GET /test/%7Bvideo.image%7D HTTP/1.1 (on Firefox Live HTTP headers). This GET generates a 404 from the server. Any clues on how to solve this? Thanks a lot :)

    Read the article

  • jQuery animation menu height

    - by StealthRT
    Hey all i have the following jsfiddle Fiddle that i need some help on. When i have my mouse over it-it expands out to a static width but, depending on the text length, it grabs it by the inner's text $('.inner').height(). Problem being is that it goes a little too far beyond the last text list item and when i roll over any of the text in the menu box it slides back up a little. How can prevent it from (1) sliding back up and (2) have the exact height needed without even having the extra space at the bottom of the box for its height? The JS: $(document).ready(function() { $('#menuSquare, .inner').mouseout(function() { theMenu('close'); }); $('#menuSquare, .inner').mouseover(function() { theMenu('open'); }); }); function theMenu(what2Do) { if (what2Do == 'open') { $('#menuSquare').stop().animate({ width: 190, //95 height: $('.inner').height(), duration:900, 'padding-top' : 10, 'padding-right' : 10, 'padding-bottom' : 10, 'padding-left' : 10, backgroundColor: '#fff', opacity: 0.8 }, 1000,'easeOutCubic') } else { $('#menuSquare').stop().animate({ width: "20", height: "20", padding: '0px', backgroundColor: '#e51937', opacity: 0.8 }, 500,'easeInCirc') } }? The HTML: <div id="menuSquare" class="TheMenuBox" style="overflow: hidden; width: 20px; height: 20px; background-color: rgb(229, 25, 55); opacity: 0.8; padding: 0px;"> <div class="inner"> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Custom Homes');">Custom Homes</p> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Full Service Hotels');">Full Service Hotels</p> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Mixed Use');">Mixed Use</p> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Office');">Office</p> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Retail');">Retail</p> <p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Select Service Hotels');">Select Service Hotels</p> </div> </div>

    Read the article

  • nth-of-type only working for 1 and 2

    - by Owen O'Neill
    I have a styling problem, I am using WordPress and want to do have the first two classes completely different to the others. My ideal situation is to have: .si-biplace:nth-of-type(3) { float:left; margin:20px 0px 0px 0px; } .si-image:nth-of-type(3) { float:left; margin:20px 0px 0px 0px; border:0px; } .si-title:nth-of-type(3) { width:100px; height:20px; margin:0px; font-size:7px; color:#FFFFFF; font-weight:bold; } They seem to work fine when it is: .si-biplace { float:left; margin:-10px 0px 0px 0px; } .si-biplace:nth-of-type(2) { float:left; margin:-10px 0px 0px 15px; } Is there a reason why it will not work with nth-of-type(3) but will with nth of type 2? I basically want different attributes for every next time the div is used but cannot have separate div classes as it runs through a php array.

    Read the article

  • JQuery. Check value of select box and textbox with same class, Is it possible?

    - by Cesar Lopez
    I have several select boxes and textboxes with the same class and I have the following statement. if ($('.selTxtClass:visible').val() == "") { $('.selTxtClass:visible').focus(); } } If I do an alert with ($('.selTxtClass:visible').val()) it comes as undefined. I want to check that the value of these elements are empty, but I cant see what is wrong with this if statement, could you give me a hand, please? Thanks a lot.

    Read the article

  • jquery selecting sibling node of the current node

    - by priyank.mp
    How do I select sibling node of the current node? Here is the snippet: <div id="main"> <a class="test" href="test.html">Hello</a> <div>Some text</div> </div> //script $(".test").click(function() { $("this:parent > div").toggle(); }); or $(".test").click(function() { $("this ~ div").toggle(); }); None of these works. I know I can access current object using $(this) but in this case I don't know how.

    Read the article

  • Is there a way to highlight specific words or numbers without inserting a span tag?

    - by Taylor
    I've got blocks of text with various specs in them and want to have jquery highlight whatever matches a specific pattern without inserting any extra html. The following is the kind of text that I've got to work with. Intel® Core™ i7 Processor 920 (2.66GHz, 8MB cache, 4.8GT/sec)/ Genuine Windows® 7 Home Premium 64bit- English/ 640 GB Serial ATA non Raid (7200 Rpm)/ 6GB 1333MHz (3x2GB) Tri Channel Memory/ Display Not Included/ 16X DVD+/- RW Optical Drive (DVD & CD read and write)/ 1.8GB NVIDIA® GeForce™ GTX260 graphics card/ Integrated HDA 7.1 Dolby Digital Audio What I'm hoping jquery can do is highlight some of the basic specs without inserting any extra html. Maybe working off a list of values matching the spec format using some wildcards where neededed? The css to select the correct tag is #list div div div+p or I could just give the p class but would rather not. Is this kind of thing possible?

    Read the article

  • jQuery indexOf select box manipulation

    - by kenny99
    Hi, I'm trying to figure out how to remove options from a select box when that option has been selected in an adjacent select box. Basically the user has the option to add multiple records here via select boxes, but I want to remove the list of options available to them so that, for example, they can't enter the same value in two select boxes. When an Add More button is clicked, I fade in the next select box container. A number of select boxes have been generated by PHP and I use JS to hide them. Each select box has a unique number appended to the ID, so i want to access those select boxes which contain the string "other_pet_types", then I want to iterate through the currently visible ones and build an array of the values which have been selected, which I will then remove from the list of options in the newly displayed select box. This is what I have so far, but it's definitely not right - I can't get the initial test on the ID to work. Any pointers greatly appreciated as i realise i'm pretty wide of the mark at the moment! var vals = new Array(); //build array with currently selected options $('p.mult_entries select').each(function(){ vals += $(this).val(); }); $("p.mult_entries:hidden:first").fadeIn("slow", function() { $(this).find(('select').attr('id').indexOf('other_pet_types') > 0).each(function(){ console.log($(this).val()); //as expected prints nothing - need to iterate through the options of the above select //once i extract the correct values, iterate through new select box and use inArray to remove options where that value already exists in one of previous select boxes }); });

    Read the article

  • jquery can't get the change event on select element

    - by user63898
    i have this code the jquery code never got triggered none of the scripts are triggered : $('select[name=privileges]').change(function(){ alert("id"); var id = $(this).find(':selected')[0].id; alert(id); $('#changevalue').val(id); }) or this: $("#privileges_select").change(function() { alert($('#privileges_select option:selected').html()); }); <form method="GET" action="create_new_user.php"> user:<input type="text" size="40" name="user_name"/> password:<input type="text" size="40" name="password"/> <select name=privileges id="privileges_select"> <option name='opt_1'>admin</option> <option name='opt_2'>ordinary</option> </select> <input type="hidden" name="item_options_id" value="" id="changevalue" /> <input type="submit" value ="create" /> <input type="reset" /> </form> in the end i like to send the selected option id in the form get

    Read the article

  • Use JQuery to target unwrapped text inside a div

    - by Chris
    I'm trying to find a way to wrap just the inner text of an element, I don't want to target any other inner dom elements. For example. <ul> <li class="this-one"> this is my item <ul> <li> this is a sub element </li> </ul> </li> </ul> I want to use jQuery to do this. <ul> <li class="this-one"> <div class="tree-item-text">this is my item</div> <ul> <li> <div class="tree-item-text">this is a sub element</div> </li> </ul> </li> </ul> A little background is I need to make an in-house tree structure ui element, So I'm using the UL structure to represent this. But I don't want developers to have to do any special formatting to use the widget. update: I just wanted to add the purpose of this is I want to add a click listener to be able to expand the elements under the li, However, since those elements are within the li the click listener will activate even when clicking on the children, So I want to attach it to the text instead, to do this the text needs to be targetable, which is why I want to wrap it in a div of it's own. So far I've come up with wrapping all the inner elements of the li in a div and then moving all inner dom elements back to the original parent. But this code is pretty heavy for something that might be much simpler and not require so much DOM manipulation. EDIT: Want to share the first pseudo alternative I came up with but I think it is very tasking for what I want to accomplish. var innerTextThing = $("ul.tree ul").parents("li").wrapInner("<div class='tree-node-text'>"); $(innerTextThing.find(".tree-node-text")).each(function(){ $(this).after($(this).children("ul")); }); Answered: I ended up doing the following, FYI i only have to worry about FF and IE compatibility so it's untested in other browsers. //this will wrap all li textNodes in a div so we can target them. $(that).find("li").contents() .filter(function () { return this.nodeType == 3; }).each(function () { if ( //these are for IE and FF compatibility (this.textContent != undefined && this.textContent.trim() != "") || (this.innerText != undefined && this.innerText.trim() != "") ) { $(this).wrap("<div class='tree-node-text'>"); } });

    Read the article

  • Tying in .addClass() with other functions?

    - by Anders H
    Assuming an accordion dropdown with the standard form of: <ul> <li> <a href="#">Main Element</a> <ul> <li> <a href="#">Dropdown Element</a> </li> </ul> </li> </ul> I'm using jQuery to expand when the parent element link is clicked: var $j = jQuery.noConflict(); function initMenus() { $j('ul.menu ul').hide(); $j.each($j('ul.menu'), function(){ $j('#' + this.id + '.expandfirst ul:first').show(); }); $j('ul.menu li a').click( function() { var checkElement = $j(this).next(); var parent = this.parentNode.parentNode.id; if($j('#' + parent).hasClass('noaccordion')) { $j(this).next().slideToggle('normal'); return false; } if((checkElement.is('ul')) && (checkElement.is(':visible'))) { if($j('#' + parent).hasClass('collapsible')) { $j('#' + parent + ' ul:visible').slideUp('normal'); } return false; } if((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $j('#' + parent + ' ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } } ); } $j(document).ready(function() {initMenus();}); To add a class to the Main Element when clicked (aka the class is enabled anytime the dropdown is expanded) I'm trying to use .toggleClass(className) without luck, most likely to my positioning. Where can I add this element to get the desired effect?

    Read the article

  • jQuery select image in div if image parent does't have a certain class.

    - by Alex
    Wordpress wraps images with captions in a div with a class of .wp-caption. I'm looking for a way to select images that don't have this div so I can wrap them in different div. (to keep a consistent border around all the images) <div class="blog-post-content"> <div id="attachment_220" class="wp-caption alignleft" style="width: 310px"> <a href="/somewhere/"><img class="size-medium wp-image-220" src="/path/to/image" alt="" width="300" height="280" /></a> <p class="wp-caption-text">Caption Text</p> </div> <p>This is the body of the post</p> </div> To test my selector, I'm just trying to add a green border. I can handle the .wrap() once the selector is working. The most promising of my attempts is: $('.blog-post-content img').parent('div:not(".wp-caption")').css('border', '2px solid green'); ... but no luck.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >