Onclick looking for input value

0

I have an html code that is inserted inside a PHP variable

And inside I look for zip, if I use

    <input alt='cep' class='text difCep' name='cep' id='cep' value='$cep'  type='text' onblur='xajax_procurarEndereco(this.value);$(\"#loading\").css(\"visibility\",\"visible\");' />

It works fine, but the user wants a search button, so I have adapted the code and there is the problem, I can not get the value of the zip. I tried with document.getElementById ("field") and $ ('# cep'). Val ();

<label id='label_cep' for='cep'>CEP</label>
    <input alt='cep' class='text difCep' name='cep' id='cep' value='$cep'  type='text' />
    <button type='button' onclick='xajax_procurarEndereco(buscar input do cep);$("#loading").css("visibility","visible");' style="padding: 6px; height: 24px; margin-left: 10px;">Buscar</button>
    
asked by anonymous 15.10.2018 / 04:18

1 answer

0

Both getElementById and the jQuery query work in this case, I can not think of a problem other than that you typed the wrong one, or used single quotation marks thus closing the quotation marks you opened in HTML. See the example: link

    
15.10.2018 / 04:31