select 单击 往textarea传值
<textarea name="tile" id="tile" class="tech" placeholder="输入本次直播的标题" value="消防工程师技术实务" style="width: 318px; height:30px ;margin-top: 5px ;margin-right: 200px;resize: none;overflow: -webkit-paged-x;"/>消防工程师技术实务</textarea>
<select style="width: 318px; height: 30px; border-radius:5px; line-height: 20px;size: 8px; margin-left: 188px; margin-top: 10px;margin-bottom: 0" id="huo">
{foreach from=$nameres item=v}
<option value="{$v.goods_name}" name_value="{$v.goods_id}" >{$v.goods_name}</option>
{/foreach}
</select>
$('#huo').change(function (){
var z = $('#huo').val();
var t = $('#tile').val();
//获取select id
var x = $(this).find("option:selected").attr('name_value');
if(t == ''){
$('#tile').val(z);
}else{
arr = t.split(",");
if(arr.indexOf(z) == -1){
re = t + ','+"\r\n"+ z;
$('#tile').val(re);
}
往input传值,在input中使用换行没有反应,只有在textarea中可以使用换行
- 获取自定义属性值 ,
var x = $(this).find("option:selected").attr('name_value');
- 在select中option 加点击事件不会有反应,要用onchange ;
- js 获取当前时间
var n = new Date();console.log(n.getMonth()); //当前月 js 获取当前时间;
``.