从json文件写入链接值 [英] writing link value from json file
本文介绍了从json文件写入链接值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用phonegap构建适用于Android的应用,并从本地json文件读取内容.
building an app with phonegap for android and reading content from local json file.
但是我无法添加链接我的输出.它没有链接也可以工作,但是当我尝试添加链接值时,它不起作用.
but i can't add link my output. it works without link, but when i try to add link value, it doesn't work.
使用此代码.
$(document).on("pagebeforeshow", "#page", function(){
$.getJSON("res/veri/content.json", function(data){
console.log(data);
var output = '';
$.each(data, function (index, value) {
output += "<li>"+value.title+"</li>";
});
$('#list').html(output).listview("refresh");
});
});
但我想添加到链接值;
but i want add to link value;
首先添加
<script type="text/javascript">
function openLink(link){
window.open(link, '_blank', 'location=yes');
}
</script>
并更改;
"<li onclick='openLink(\"+"value.link+"\")' />"+value.title+"</li>";
但是,它不起作用..如何解决该错误.谢谢.
but, it doesn't works.. how can fix the error. thanks.
推荐答案
'<li><a href="' + value.link + '" data-rel="external">' + value.title + '</a></li>';
使用此代码.
这篇关于从json文件写入链接值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文