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
637 views
in Technique[技术] by (71.8m points)

javascript - Changing "src" attribute of <script>

Is it possible to change the "src" attribute of an existing <script> element using Jquery.attr()? It seemed like a simple way to get JSONP to work but I am not able to make this work for me.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

It turns out that a script's src can only be set once! It is not possible to change the src attribute of an existing <script> element in the DOM. However, a dynamically created <script> element can have its source set (but exactly once!)


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

...