Search Results

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

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

  • Help with manipulating child/parent elements with jQuery

    - by Mohammad
    Currently I have this JQuery script var img = $(this); img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); which successfully turns the following: <img src="photo.jpg" alt="caption"> into this <div class="photo"> <img src="photos.jpg" alt="caption"/> <p>caption</p> </div> All is well unless the image has a link as a parent; <a href="#"><img since I want it to be correct html (I'm fussy) improving the resulting outcome bellow would be satisfactory <a href="#"> <div class="photo"> <img src="photos.jpg" alt="caption"/> <p>caption</p> </div> </a> to this: <div class="photo"> <a href="#"> <img src="photos.jpg" alt="caption"/> </a> <p><a href="#">caption</a></p> </div> </a> This is my jQuery script so far (which doesn't work bc I'm a noob) aha if(img.parent('a')){ var targetLink = img.parent('a').attr('href').val(); img.parent('a').wrap('<div class="photo"></div>'); img.parent('div').append('<p><a href="'+targetLink+'">' + img.attr("alt") + '</p></a>'); }else{ img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); }; Any advice, or help will be greatly appreciated : ) Thank You! Update *Answer* (works but looks sloppy) I'm editing it atm; if(img.parent('a').length){ var targetLink = img.parent().attr('href'); img.parent().wrap('<div class="photo"></div>'); var divTarget = img.parent('a').parent('div'); divTarget.append('<p><a href="'+targetLink+'">' + img.attr("alt") + '</p></a>'); }else{ img.wrap('<div class="photo"></div>'); img.parent().append("<p>" + img.attr("alt") + "</p>"); };

    Read the article

  • jQuery selector question

    - by Jakey
    I have a span and an anchor inside a table cell. I have the anchor set up to show a tooltip. I would like the text inside the span to be used for the tooltip. How can I select this text in jQuery? <td class="row-head" colspan="5"><span class="tip-text">Complete Coverage</span><a href="#" class="help"></a></td> JQuery code - the current selector always finds the first instance only for all tips. $(document).ready(function() { $('.help').qtip({ style: { name: 'cream', tip: true }, content: { text: $(this).find('span.tip-text').html() } }); }); Thanks

    Read the article

  • selenium cannot find element with class in IE

    - by Rob
    I'm using selenium_client with cucumber, webrat + IE As you'd expect, Firefox works fine. I've tried the following: selenium.is_visible("css=#flash .flash_notice") selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice]") selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice]')") both cannot find the element. I think it must be something to do with IE, looking closer at the html selenium returns from IE... It looks like this: <UL id=flash> <LI className=flash_notice>Deleted</LI> </UL> Notice IE returns the class attribute as className, is this confusing selenium? How can I get round this so that I can use the same statement for selenium using IE and Firefox Just to confuse us even more, this example works, confirming its something to do with checking the class attribute selenium.is_visible("xpath=//*[@id='flash']/*[. =\'Deleted\']")

    Read the article

  • jQuery click event still firing on filtered element

    - by Phil.Wheeler
    I'm trying to filter button events based on whether they have a CSS class assigned to them or not. Assume I have a button like this: <button id="save-button" class="ui-state-default ui-corner-all">Save</button> I want to get jQuery to select all buttons that currently do not have a class of "ui-state-disabled". The selector I'm using looks like this: $('#save-button:not(.ui-state-disabled)').click(function() { ... }); When the button is clicked, I'll call a different function, do some stuff and then add the class 'ui-state-disabled' to the button. However the button still continues to accept click events. I'm guessing this is because of two possible causes: The event binder looks only at the initial state when binding the click event and doesn't recognise that a new class has been added later on My filter ['... :not(.ui-state-disabled)] is not correct Any observations?

    Read the article

  • Points in CSS specificity

    - by Sam
    Researching specificity I stumbled upon this blog - http://www.htmldog.com/guides/cssadvanced/specificity/ It states that specificity is a point-scoring system for CSS. It tells us that elements are worth 1 point, classes are worth 10 points and IDs are worth 100 points. It also goes on top say that these points are totaled and the overall amount is that selector's specificity. For example: body = 1 point body .wrapper = 11 points body .wrapper #container = 111 points So, using these points surely the following CSS and HTML will result in the text being blue: CSS: #a { color: red; } .a .b .c .d .e .f .g .h .i .j .k .l .m .n .o { color: blue; } HTML: <div class="a"> <div class="b"> <div class="c"> <div class="d"> <div class="e"> <div class="f"> <div class="g"> <div class="h"> <div class="i"> <div class="j"> <div class="k"> <div class="l"> <div class="m"> <div class="n"> <div class="o" id="a"> This should be blue. </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> RESULT: http://jsfiddle.net/hkqCF/ Why is the text red when 15 classes would equal 150 points compared to 1 ID which equals 100 points?

    Read the article

  • jQuery li:has(ul) selector issue

    - by sushil bharwani
    I was creating a tree using UL LI list and jQuery. I used a jQuery Selector jQuery(li:has(ul)) to find all the list nodes having childs and then added a click event to it. jQuery(li:has(ul)).click(function(event) { jQuery(this).children.toggle(); jQuery(this).css("cursor","hand"); }); This works for me except i dont understand why i get a cursor hand and click event triggering even when i take mouse pointer to childs of my selected li <li> Parent // it works here that is fine <ul> <li> child1 // it works here i dont understand need explanation </li> <li> child2 // it works here i dont understand need explanation </li> </ul> </li>

    Read the article

  • Binding KeyUp event to Input Field

    - by user306686
    I am dynamically generating textboxes in ruby using <%0.upto(4) do |i| % <%= text_field_tag('relative_factor[]', @prefill_values[:relative_factor][i],:size = 6,:maxlength = 5) % <%end% it generates following HTML markup Another set of textboxes: <%0.upto(4) do |i| % <%= text_field_tag('rating_factor[]', @prefill_values[:relative_factor][i],:size = 6,:maxlength = 5) % <%end% it generates following HTML markup I have one more textbox: ..... I want to update id="rating_factor_" textboxes as the value in either id="multiple" textbox changes or id="relative_factor_" textboxes changes. E.g. id="multiple" textbox = 5 id="relative_factor_" value= 0.0 textbox = 1 id="relative_factor_" value= 1.0 textbox = 2 id="relative_factor_" value= 2.0 textbox = 3 id="relative_factor_" value= 3.0 textbox = 4 id="relative_factor_" value= 4.0 textbox = 5 I want to show (multiple multiple and relative_factor_ and show) id="rating_factor_" value= 0.0 textbox = 5 id="rating_factor_" value= 1.0 textbox = 10 id="rating_factor_" value= 2.0 textbox = 15 id="rating_factor_" value= 3.0 textbox = 20 id="rating_factor_" value= 4.0 textbox = 25 Now if user changes, id="relative_factor_" value= 1.0 textbox as 1.5 then id="rating_factor_" value= 1.0 textbox should be updated as 7.5 To achieve above goal, I tried binding #relative_factor_ to keyup event but as id is same for all i.e.#relative_factor_, it returns value for first textbox i.e. id="relative_factor_" value= 0.0. Please guide me to crack this problem. Thanks in Advance.

    Read the article

  • jQuery :contains(unicode_characters)

    - by SeanJA
    I have an element like this: <span class="tool_tip" title="The full title">The ful&#8230;</span> This seems to work: jQuery('span:contains(…)'); But this does not: jQuery('span:contains(&#8230;)'); I am pretty sure that it would be bad to use the first one because if someone else saves the file, or the browser decides to get the file in a different character set for some reason things will not work. There has to be a way to properly select this span, right?

    Read the article

  • How do i select the 1st and then every 4th row in a html-table with nth-child()-selector?

    - by Nils
    Ok, math isn't my strong side, I admit it. All I want to do is to select the first, 5th, 9th, 13th, 17th etc row in a html-table. Can anybody with better math-skills point me in the right directionor perhaps supply a "nth-child-for-dummies" guide? I tried nth-child(1n+4) (which selects the 4th row and everyone after), and i also tried nth-child(0n+4) which selects the fourth row and nothing after that. Thanks in advance.

    Read the article

  • Accessing Element Count and Values Within a Hidden Div

    - by Tegan Snyder
    I'm having trouble grabbing the TR count in JQuery of a table that inside a DIV set to be hidden. Here is an example: <div id="questions" style="display: none;"> <table id="tbl_questions"> <thead> <tr> <th>Question</th> <th>Weight</th> </tr> </thead> <tbody> <tr id="q0"> <td id="td_question0">Some Question 0</td> <td id="td_wieght0">Some Weight 0</td> </tr> <tr id="q1"> <td id="td_question1">Some Question 1</td> <td id="td_wieght1">Some Weight 1</td> </tr> </tbody> </table> </div> Note the table is within the containing div. It's set to display: none. When I try to run this JQuery code it returns 0. var question_count = $("#tbl_questions> tr").size(); alert(question_count); Any ideas? I'm try to locate the count so I can then build an array of each question and weight in the table. Since the ID's provide me with an index this should be simple, but is the fact that it is contained in a hidden DIV going to be a problem just as the above question? Thanks, Tegan Snyder

    Read the article

  • What does this JavaScript error mean?

    - by Tommy
    Using the “Venkman” JavaScript debugger for Mozilla and getting the following error: XML Parsing Error: not well-formed Location: x-jsd:source?location=http%3A%2F%2F192.168.1.150%2Fscript.js&instance=337 Line Number 557, Column 50:<line><margin x='t'> - </margin><num> 554</num> ?? valid = false;</line> Functions works but I don't understand the error. Any help is appreciated. Thanks. function ValidateCheckBoxes() { var valid; $(document).ready(function(){ if($('input[@name=boxesA]:checked').size() == 0) {     valid = false; } else { valid = true; } }); return valid; }

    Read the article

  • On select show multiple divs?

    - by chaser7016
    Hi I am trying when a user chooses an airline from dropdown seen here that two additional drop downs appear for departing airport and arrival airport. I have coded it to work when one chooses American Airlines from drop down, but I need different departing and arrival airports to appear for the various a user may choose. Anyone know how that can be done? thanks

    Read the article

  • CSS being ignored in IE & FFox but not Chrome

    - by Grant
    Hi, i am styling a navigation menu using the following css. I have found that it works perfectly in chrome but absolutely none of the css is beign applied in firefox or IE. Is there something obvious that i havent done or have done here? <style type="text/css"> #ddm { margin: 0; padding: 0; } #ddm li { float: left; list-style: none; font: 8pt Tahoma, Geneva, sans-serif; } #ddm li a { display: block; padding: 5px 12px; text-decoration: none; border-right: 1px solid white; width: 70px; white-space: nowrap; color:Red; border: none; } #ddm li a:hover { color:White; background-color:#444444; } #ddm li ul { margin: 0; padding: 0; position: absolute; visibility: hidden; } #ddm li ul li { float: none; display: inline } #ddm li ul li a { width: auto; } #ddm li ul li a:hover { } </style> <ul id="ddm"> <li> <ul> <li><a href="#">test 1</a></li> <li><a href="#">test 2</a></li> </ul> </li> </ul>

    Read the article

  • Expanding / grow a JQuery element selection?

    - by HipHop-opatamus
    In the Jquery example below, I would like to expand $(this) before it is cloned, so it includes everything contained in the parent class "comment". How do I do this? I've tried using ReplaceWith($(this).parent('.comment').clone()... and it does not work! $(document).ready( function(){ $('.forumthreadtitle').siblings().hide(); $('.forumthreadtitle').click( function() { $('#first-post').replaceWith($(this).clone().attr('id','first-post')); });

    Read the article

  • Jquery : How to load a function after some interval or after end of another function or event

    - by Maju
    I need to run a function 'setNotifications()' after a timed delay or at the end of completion of the previous animation('#topannounce' animation).But jQuery is not running the 'setNotifications()'after the animation. What should I do? or is there a better way to run the function?Plz hlp.Thanx. Here is the jQuery I have. $('a#resetbtn').bind('click', function(){ //setNotifications(); $.cookie('notificationBar', 'open'); //$('#topannounce').animate({opacity: 1.0}, 3000).fadeIn('slow'); $('#topannounce').fadeIn('slow'); setNotifications(); }); function setNotifications() { alert("load:setNotifications..."); }

    Read the article

  • How to get multiple html() strings in jQuery

    - by Bryan
    I'm pretty new to jQuery... so far I'm impressed. But I encountered a situation today that is giving me trouble. I want to use .html() to get some raw text and use that in a selector, but that function only returns the first element. In the following structure, how can I get ALL of the "toggle_containerLG" divs to show when I click on the trigger "Some Header"? <h6 class="trigger active">Some Header</h6> <ul> <li><a href="#" class="trigger">Title One</a></li> <li><a href="#" class="trigger">Title Two</a></li> <li><a href="#" class="trigger">Title Three</a></li> </ul> <div class="toggle_containerLG" id='Title_One'></div> <!-- show these! --> <div class="toggle_containerLG" id='Title_Two'></div> <div class="toggle_containerLG" id='Title_Three'></div> <div class="toggle_containerLG" id='Title_Four'></div> <!-- not this one! --> I can't use $(".toggle_containerLG") because there are others I don't want to expand... I just want the ones listed under "Some Header". Seems like there should be an easy way to do it... and I'm just missing it because I don't know jQuery very well.

    Read the article

  • What is the performance impact of CSS's universal selector?

    - by Bungle
    I'm trying to find some simple client-side performance tweaks in a page that receives millions of monthly pageviews. One concern that I have is the use of the CSS universal selector (*). As an example, consider a very simple HTML document like the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Example</title> <style type="text/css"> * { margin: 0; padding: 0; } </head> <body> <h1>This is a heading</h1> <p>This is a paragraph of text.</p> </body> </html> The universal selector will apply the above declaration to the body, h1 and p elements, since those are the only ones in the document. In general, would I see better performance from a rule such as: body, h1, p { margin: 0; padding: 0; } Or would this have exactly the same net effect? Essentially, what I'm asking is if these rules are effectively equivalent in this case, or if the universal selector has to perform more unnecessary work that I may not be aware of. I realize that the performance impact in this example may be very small, but I'm hoping to learn something that may lead to more significant performance improvements in real-world situations. Thanks for any help!

    Read the article

  • Not able to get siblings value from table row

    - by Sullan
    Hi All, I am trying to get values from adjacent columns, when a radio button is clicked for that row. I'm able to do so, but the problem I'm facing, when there are more elements in the radio button column, then i am getting null values(i.e 2nd row is not working). Please help...Code is all follows <table id="dist_list" class="data"> <tbody> <tr> <td> <input type="radio" value="636406" name="distRG" id="radio_7" /></td> <td class="selected">Company 1</td> <td class="siteId">1234</td> <td class="siteName">First Company Name</td> </tr> <!-- Not able to get values from this row, since there are more elements in it --> <tr> <td> <span class="jqTransformRadioWrapper"><a rel="distRG" class="jqTransformRadio" href="#"></a> <input type="radio" value="636406" name="distRG" id="radio_2" /> </span></td> <td class="selected">Company 2</td> <td class="siteId">2345</td> <td class="siteName">Second Company Name</td> </tr> <tr> <td><input type="radio" value="636406" name="distRG" id="radio_3" /></td> <td class="selected">Company 3</td> <td class="siteId">3456</td> <td class="siteName">Third Company Name</td> </tr> <tr> <td><input type="radio" value="213584" name="distRG" id="radio_4" /></td> <td class="selected">Company 4</td> <td class="siteId">4567</td> <td class="siteName">Fourth Company Name</td> </tr></tbody></table> jQuery script $("input[name=distRG]").click(function() { var owner = $(this).parent().siblings('td.selected').text(); var siteId = $(this).parent().siblings('td.siteId').text(); var siteName = $(this).parent().siblings('td.siteName').text(); alert(owner); alert(siteId); alert(siteName); });

    Read the article

  • Cloning a selector + all its children in jQuery?

    - by HipHop-opatamus
    I'm having trouble getting the following JQuery script to function properly - its functionality is as follows: 1) Hide the content below each headline 2) Upon clicking a headline, substitute the "#first-post" with the headline + the hidden content below the headline. I can only seem to get the script to clone the headline itself to #first-post, not the headline + the content beneath it. Any idea why? <HTML> <HEAD> <script src="http://code.jquery.com/jquery-latest.js"></script> </HEAD> <script> $(document).ready( function(){ $('.title').siblings().hide(); $('.title').click( function() { $('#first-post').replaceWith($(this).closest(".comment").clone().attr('id','first-post')); $('html, body').animate({scrollTop:0}, 'fast'); return false; }); }); </script> <BODY> <div id="first-post"> <div class="content"><p>This is a test discussion topic</p> </div> </div> <div class="comment"> <h2 class="title"><a href="#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> <div class="comment"> <h2 class="title"><a href="#2">2nd Post</a></h2> <div class="content"> <p>this is 2nd reply to the original post</p> </div> <div class="test">2nd post second line</div> </div> </div> <div class="comment"> <h2 class="title"><a href="#3">3rd Post</a></h2> <div class="content"> <p>this is 3rd reply to the original post</p> </div> <div class="test">3rd post second line</div> </div> </div> </BODY> </HTML>

    Read the article

  • FancyBox, Obtaining an ATTR of the item clicked

    - by nobosh
    I have the following lines of code: $("a.quickview").fancybox({ ajax : { type : "POST", data : 'itemID=' + $(this).attr("name") } }); Which is binding on: <a name="614" class="quickview" href="/URL/index.cfm">quick view</a> I want data to post as itemID=614, but $(this).attr("name") is coming back as undefined? What am I doing wrong? Thanks

    Read the article

  • How Do i handle both the checked and clicked events in Jquery

    - by Someone
    Say I have a form and onload of that form I have 2 radio buttons say "yes" or "no " I have set of action to perform when we select either one radio button .Say if we select "yes " //Onload of Form if(("#yes:checked")){ $("#table").show(); $("#div1").show(); $("#div2").show(); alert("Checkedd on Load"); } //for click $("#yes").bind('click',function(){ $("#table").show(); $("#div1").show(); $("#div2").show(); alert("Checked by Click"); }); }); Iam Writing the same repeated lines of code for two similar set of events .Is There anyway to combine the "Checked" and "Clicked" events Say if i do inthis way than "Checked" doesnot get called untill "Clicked"?Is there any other way to do it. $("#yes").bind('click',function(){ if(("#yes:checked")){ $("#table").show(); $("#div1").show(); $("#div2").show(); alert("Checked by Click"); } }); });

    Read the article

  • css Checkbox Label Selector

    - by HW90
    I'm developing a MVC3 application and need to select the checkboxes label. In ASP MVC3 you have helper methods which creat a part of the code. So the code for a checkbox looks like this: <input id="Jumping_successleicht" type="checkbox" value="true" name="Jumping_successleicht"> <input type="hidden" value="false" name="Jumping_successleicht"> <label for="Jumping_successleicht"> <span>leicht (4)</span> </label> Now I've thought I can use following code to select the label: input[type=checkbox] + label { background: url("../../Images/Controls/Checkbox.png") no-repeat scroll left center transparent; clear: none; cursor: pointer; margin: 0; padding: 5px 0 4px 24px; } But it does not work. It looks like label and input have to be next to each other. Does any ony have a solution how to solve this problem?

    Read the article

  • how to use trigger in Jquery to pass parameter data as well as control (this)

    - by Shantanu Gupta
    I am trying to use same validation funtion for all my controls. But I dont know much in jquery and not been able to pass event handler to the trigger. I want to pass textbox id to my custom function. How can i do this <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#txtFirstName").bind('focusout', function() { $(this).trigger("customblurfocus",[$(this).val(), $(this).val() + " Required !", "Ok !"]); } ); $(this).bind('customblurfocus',function(defaultInputValue,ErrorMessage,ValidMessage) {alert($(this).val()); if($(this).val()=="" || $(this).val()==defaultInputValue) { $(this).val(defaultInputValue); $(this).siblings("span[id*='error']").toggleClass("error_set").text(ErrorMessage).fadeOut(3000); } else { $(this).siblings("span[id*='error']").toggleClass("error_ok").text(ValidMessage).show(1000); } } ); }); </script>

    Read the article

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