Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
137 views
in Technique[技术] by (71.8m points)

javascript - I Append Input Field and Than i am trying to do fire event on the same input But not working

$(function(){   //Fetch Questions From JSON File "questions.js"   let
    fetchQuestions = () = {
        $.getJSON("json/questions.json", function(obj){
            $.each(obj, function(key, value) {
                $(".js-questions").append(`
                   <li class="questions__question"
                     <div
                       <span${value.count}</span
                       ${value.question}
                       <input type="text" class="questions__answer js-answer" answer="${value.answer}" onfocus="focusField(this)"/
                     </div
                   </li
                `);
            });
        });   
    }


    fetchQuestions();
 
 
    let focusField = (element) = {
        $(element).css("background-color", "yellow");   
    }

})
question from:https://stackoverflow.com/questions/66059278/i-append-input-field-and-than-i-am-trying-to-do-fire-event-on-the-same-input-but

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...