更新时间:2023-02-03 08:32:54
您可能会使用eval()
,但是您正在做的事情似乎是一个非常糟糕的主意:
You would use eval()
but what you are doing seems like a really bad idea:
var x = $('#id').attr('jq');
eval(x);
这很不好的原因是您没有将功能与结构分开. HTML旨在描述结构,而不是交互性和功能.
The reason this is bad, is you are not separating function from structure. HTML is meant to describe structure, not interactivity and function.
JavaScript旨在提供这种交互和增强功能,而不是结构.像这样使用jQuery内联违反了这种分隔.只是值得深思的……
JavaScript is meant to provide that interaction and enhancement, but not structure. Using the jQuery inline like that is a violation of that separation. Just food for thought...