jimfog Posted September 10, 2013 Share Posted September 10, 2013 I have 4 input elements and 4 labels,one for each. In addition each of these label elements have for attributes. I want to target and hide a specific label, the one having for='"wwwaddress" but I cannot, instead all labels are hidden. See the fiddle here: http://jsfiddle.net/fiddlehunt/5rSdf/ What am I doing wrong? Link to comment Share on other sites More sharing options...
Markh96 Posted September 10, 2013 Share Posted September 10, 2013 (edited) You are trying to hide the wwwaddress label when you target it? Or you just want to hide the wwwaddress input using Javascript? Edited September 10, 2013 by Markh96 Link to comment Share on other sites More sharing options...
jimfog Posted September 10, 2013 Author Share Posted September 10, 2013 You are trying to hide the wwwaddress label when you target it? Or you just want to hide the wwwaddress input using Javascript? Everything is done js.EITHER WAY. I do not understand your first question. I am just trying to hide the label, forget the input element for now Link to comment Share on other sites More sharing options...
Ingolme Posted September 10, 2013 Share Posted September 10, 2013 I don't rememebr exactly what the jQuery attr() function does, but you probably are just setting the value of the for attribute to "wwwaddress" on all elements with class "label". What you want to do is select the element that has attribute for="wwwaddress" so here's the proper selector: .label[for=wwwaddress] Link to comment Share on other sites More sharing options...
davej Posted September 10, 2013 Share Posted September 10, 2013 (edited) Yeah, Foxy has it. This works... $(".label[for='wwwaddress']").hide();//or//$("label.label[for='wwwaddress']").hide(); Edited September 10, 2013 by davej Link to comment Share on other sites More sharing options...
jimfog Posted September 11, 2013 Author Share Posted September 11, 2013 (edited) The problem now though, it is that the hidden element occupies the space in the form-it is seen as large empty space. The goal is that the space is NOT occupied. I FIXED..almost, if there is a problem I will repost. Edited September 11, 2013 by jimfog Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2013 Share Posted September 11, 2013 I'm not sure what hide() does, but if you set the CSS display to "none" it should not occupy any space at all. Here's how you can set CSS properties in jQuery: http://w3schools.com/jquery/jquery_css.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now