this is my jsfiddle
My Question is suppose I type something in div block and then I click on “No” then that block disappaer.
But When I click on “yes” again all values that are there are still on the InputFields.
My requirement is I am expecting that those values should be clear when I switch to field “No” in my case
How do I acheive this?
You would need JS to to do that (or add a reset button perhaps). CSS won’t be able to do this alone.
You can hide and show things but you can’t change their values with css.
There are some jquery plugins that do similar but you probably don’t need something as complex for just a few inputs.
I like a good challenge. This is based off your reset idea.
You’d obviously need a bit more styling to this but it’s a rough demo.
I have to go shower for work otherwise I’d keep styling it to make it more similar.
Perhaps I could add some CSS in there to perhaps check if the “yes” ISN’T checked and then style the “no” accordingly. I’ll play with this when I get to work…
It’s a damn shame the not() pseudo class doesn’t support pseudo states as arguments. E.g.
This could have gone so far…
Yes,that’s what I meant but I didn’t think to style the reset button as a radio . The main problem with that approach is that the whole form gets reset so if there is other data being presented then you would need separate forms for each.
Yeah the whole approach needs to be scrapped anyway though since :not() doesn’t allow pseudo states . Such a buzzkill.
Just thought I’d have fun with it. I never get to experiment these days.
Yes, these are the types of things I like to play with also
You made a checked state for the reset-button, just as a radio button, nice.
Played with your demo trying to make it look like a radio button too. Couldn’t get closer than this in the setup, sure crossbrowser differs anyway. http://jsfiddle.net/b0hbk495/30/
I didn’t really even try to style it since it’s still a b**** to style form elements (kinda sad really) but just thought I’d update you all .
If I am using JQuery to show and hide a block
Is there any better solution using JS
Here is my code
You don;t seem to be using jquery to hide anything there so can you clarify the question? You are still using Ryan’s CSS demo.
Here is my jquery code
for my post reference
If you are still talking about removing the values from the inputs then you could add this ( $(“#highSchool input[type=text]”).val(‘’); ) to the js.
Suppose I have a “select” tag also in my div block
And after closing tag I want that should also be in “Select Course”
not indivitual course that are selected
How do I acheive this
Try something like this.
$("#highSchool select option:eq(0)").attr("selected", "selected");
This seems to be working:
- Choose Yes
- Type Paul on the first line
- Select Pakistand
- Choose No
- Choose Yes again
All fields are empty, and the select says Select Course once again.
That seems to be working fine.
What about it is not working for you?