Reputation: 267
My html is look like below (it's not a html I'm echoing this using PHP. And it has lot of <li></li>
with same 3 inputs content. It's a dynamically generated one)
<li><span class='add-on'></span>" .
"<input class='' type='text' value='' />
<input class='picker' type='hidden' value='' name='' />
<input class='datepicker' type='text' />
</li>
I want to select first input using CSS. I tried first-child but no luck.we can't put any class or Id to that first input. Because I was write another JS script to find non class inputs. So I want to select that first input using jQuery. And I need to put that first input value and datepicker class value to hidden input value. I was try following script. But I don't know how to select that input using jQuery.
jQuery
var getDate = $(".datepicker").val();
var getMark = $("I want to any select to select first input").val();
var plusVal = getDate + getMark;
$(".picker").val(plusVal);
How to do it?
Upvotes: 0
Views: 87
Reputation: 11078
CSS:
li > span + input { /* styles here */ }
jQuery:
$('li > span + input').val();
Upvotes: 2
Reputation: 4234
If you can depend on CSS3, then you can use li > input:first-of-type
or li > input:nth-of-type:(1)
. Otherwise you could use li > span + input
Upvotes: 0