Attribution of the attribu by jQuery



  • $(function() {
      $('.row_new > #btn_edit').on('click', function(event) {
        event.preventDefault();
        var rtitle = $(this).siblings('h1').text();
        $(this).siblings('h1').html('<form id="f_news"><input type="text" name="" id="f_news_title" value=""></form>');
        $('#f_news_title').attr('value', rtitle);
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="id" class="row_new">
      <h1>Какой-то заголовок</h1>
      <a id="btn_edit" href="">Редактировать</a>
    </div>

    I can't get attribution. value variable value rtitle♪ Can you tell me what I'm doing wrong?



  • Replace.

    $(this).siblings('h1').html('<form id="f_news"><input type="text" name="" id="f_news_title" value=""></form>');
    $('#f_news_title').attr('value', rtitle);
    

    $(this).siblings('h1').html('<form id="f_news"><input type="text" name="" id="f_news_title" value="' + rtitle + '"></form>');
    

    P.S. That's it. name="" Very strange.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2