如何在返回新的div的JQuery函数中编写代码? [英] How to write in JQuery function which return new div?

查看:80
本文介绍了如何在返回新的div的JQuery函数中编写代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在返回新div的JQuery函数中编写代码? (我喜欢使用参数来使某个对象起作用,基于该对象和属性,我需要在div中返回不同的颜色和文本.例如:如果我将FI漆成红色并写成"fire",如果我将WI漆成蓝色并写成浪费").谁能帮忙

How to write in JQuery function which return new div ? ( I get like parameter to function some object, base on that object and properties I need to return different color and text in div. Example: if I got F I paint red and write "fire", if I got W I paint blue and write "watter" ). Can anybody help

推荐答案

function getADiv() {
    return $('<div/>', {
        text: 'hello',
        color: 'red'
    });
}

这篇关于如何在返回新的div的JQuery函数中编写代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆