doudao2954 2013-09-26 17:39
浏览 20
已采纳

如何使用Jquery函数来编写Div而不是Textbox?

I have a jquery function which gets data from a json php mysql. And the results are appearing in textboxes

function renderDetails(wine) {
$('#Id').val(wine.id);
    $('#question').val(wine.question);
    $('#answer').val(wine.answer);
    $('#link').val(wine.link).html();
}

The textboxes in HTML are like this

<label>link:</label>
<input type="text" id="link" name="link"/> 

Instead of a text box I would like to bring the link to a div!

<p id="link">This is where the link should appear.</p>

How would you write the jquery in order to feed the DIV ???

  • 写回答

5条回答 默认 最新

  • dsq2015 2013-09-26 17:42
    关注

    Well, for starters, that's not a div. That's a p. But beyond that, you can simply use the .text() function to set the contents of any such element:

    $('#link').text(wine.link);
    

    Or, for HTML content:

    $('#link').html(wine.link);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏