我继承了一个包含以下内容的代码库:
Javascript / JQuery
('.text_transition').on('change', function()
{
var keycode = $(this).val();
var $el = $(this).closest('.js-builder').find('.js-preview');
var $new_p;
var $parent = {};
var attributes = [ 'font-family', 'font-size', 'top', 'position', 'left', 'width', 'height', 'text-align', 'color' ];
var attr_object = {};
for ( var prop in attr_object )
{
if ( attr_object.hasOwnProperty( prop ) )
{
// ....Do something
}
}
});
HTML
<div class="inputContainer">
<select name="page_1_text_transition" class="text_transition">
<option value="swing_sync" data-json="{"id":6,"unique":"swing_sync","name":"Swing + Sync","order":0}">Swing + Sync</option>
<!-- etc.... -->
</select>
</div>
非常基础......在改变时,做点什么。
我无法弄清楚它是如何处理对象attr_object
为空的?