How do I get a value of a using jQuery?

后端 未结 12 1450
青春惊慌失措
青春惊慌失措 2020-11-28 07:53

This is basic.

How do I get the value \'This is my name\' of the above span?

This is my name
12条回答
  •  无人及你
    2020-11-28 08:09

    You could use id in span directly in your html.

    Client
    

    Then your jQuery code would be

    $("#span_id").text();
    

    Some one helped me to check errors and found that he used val() instead of text(), it is not possible to use val() function in span. So

    $("#span_id").val();
    

    will return null.

提交回复
热议问题