Javascript for ... in循环使用空对象

时间:2016-09-13 08:54:00

标签: javascript jquery html

我继承了一个包含以下内容的代码库:

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="{&quot;id&quot;:6,&quot;unique&quot;:&quot;swing_sync&quot;,&quot;name&quot;:&quot;Swing + Sync&quot;,&quot;order&quot;:0}">Swing + Sync</option>

        <!-- etc.... -->
    </select>
</div>

非常基础......在改变时,做点什么。

我无法弄清楚它是如何处理对象attr_object为空的?

0 个答案:

没有答案