开发者

.append and .html in one line jquery

开发者 https://www.devze.com 2022-12-22 08:37 出处:网络
I 开发者_如何学Cwant to .append to a div and pass the value on as html using jQuery I want to pass a hidden <input type=hidden....> append and sending it as .html

I 开发者_如何学Cwant to .append to a div and pass the value on as html using jQuery

I want to pass a hidden <input type=hidden....> append and sending it as .html

$('#here').append(va_lue).html();

Hoping you guys understand now

Thanks Jean


OK, it's still not clear what you are asking, but I think it's this:

$('#yourDivId').append($('<input/>')
  .attr({'type': 'hidden', 'name': 'nameOfParameter', 'value': 'your value'})
);

That will add a new <input> tag to a div whose "id" is "yourDivId". The input field will be of type "hidden", and will have whatever name and value you want.

If you have a block of HTML for your input field, then you would do something like this (as @psychotik already wrote):

var inputFieldHtml = "<input type='hidden' name='whatever' value='balloons'>";
$('#yourDivId').append($(inputFieldHtml));


This? var newHtml= $(newHtml).appendTo( $('#placeToInsert') ).html();

0

精彩评论

暂无评论...
验证码 换一张
取 消