我只需要一个jQuery片段来完成img src中的前置,即
<img src='/img/picture1.jpg' />
Run Code Online (Sandbox Code Playgroud)
代码片段jQuery将预先添加此url
http://cdn.something.com/
Run Code Online (Sandbox Code Playgroud)
所以在片段jQuery之后,它变得像
<img src='http://cdn.something.com/img/picture1.jpg' />
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
到目前为止我写了类似的东西
$().ready(function(){
var cdn ='http://cdn.something.com';
$('img').attrib('src', cdn);
Run Code Online (Sandbox Code Playgroud)
});
然而它被替换为src而不是pre
<exam>
<question type="multichoice">
<name>
<text>Demo Imported Question</text>
</name>
<questiontext format="html">
<text>What is SEO?</text>
</questiontext>
<answer fraction="0">
<text>Son of English Organization</text>
<feedback><text>WRONG</text></feedback>
</answer>
<answer fraction="100">
<text>Search Engine Optimization</text>
<feedback><text>Right on!</text></feedback>
</answer>
<answer fraction="0">
<text>Silver of England Office</text>
<feedback><text>Ooops!</text></feedback>
</answer>
<questiontext format="html">
<text>How many stars are there on US flag ?</text>
</questiontext>
<answer fraction="0">
<text>46</text>
<feedback><text>WRONG</text></feedback>
</answer>
<answer fraction="100">
<text>52</text>
<feedback><text>Right on!</text></feedback>
</answer>
<answer fraction="0">
<text>54</text>
<feedback><text>Ooops!</text></feedback>
</answer>
</question>
</exam>
Run Code Online (Sandbox Code Playgroud)
以上是一个虚拟测试xml,我喜欢通过Java代码片段读取并简单地输出为
Question : what is seo?
answer: Son of English Organizatio
answer: …Run Code Online (Sandbox Code Playgroud)