Answer the question
In order to leave comments, you need to log in
How to return value from .click()?
Good afternoon.
Need your advice:
Task
There is a form with open and hidden fields.. they are connected. Example:
(Открытое)
<span class="twitter-typeahead" style="position: relative; display: inline-block;">
<input class="typeahead form-control tt-hint" value="" type="text" readonly="" autocomplete="off" spellcheck="false" tabindex="-1" dir="ltr" style="position: absolute; top: 0px; left: 0px; border-color: transparent; box-shadow: none; opacity: 1; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">
<input class="typeahead form-control tt-input" name="year_autocomplete" value="" type="text" id="year_autocomplete" autocomplete="off" spellcheck="false" dir="auto" style="position: relative; vertical-align: top; background-color: transparent;">
<pre aria-hidden="true" style="position: absolute; visibility: hidden; white-space: pre; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; word-spacing: 0px; letter-spacing: 0px; text-indent: 0px; text-rendering: auto; text-transform: none;">2</pre>
<div class="tt-menu" style="position: absolute; top: 100%; left: 0px; z-index: 100; display: none;"><div class="tt-dataset tt-dataset-0"><p class="tt-suggestion tt-selectable">2015</p><p class="tt-suggestion tt-selectable">*</p></div></div></span>
<input name="year" value="1" type="hidden" id="year">
$(function(){
var hiddenId = $("input.typeahead").click(function(){
var idInputField = $(this).attr("id");//***_complete
var result = idInputField.split("_").slice(0,1);//****
//console.log(result);
return result;
});
console.log(hiddenId);
//if(!$("#"+hiddenId).value){
//
//}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question