开发者

Div won't close and text is not placed in textarea

function EditorDivOpen(a){
    $('#'+a).show();
}

function EditorDivClose(a){
    $('#'+a).close();
}

function EditorDivFill(a,b){
    var init;
    if(a == 'smileys'){
        init = '<img src="data/img/smileys/sad.png" onclick="EditorTextFill(\':(\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/happy.gif" onclick="EditorTextFill(\':)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/angelnot.gif" onclick="EditorTextFill(\'0:=)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/angry.gif" onclick="EditorTextFill(\'=(\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/blush.gif" onclick="EditorTextFill(\':@\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/cencored.png" onclick="EditorTextFill(\':*\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/confused.gif" onclick="EditorTextFill(\':?\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/cry.png" onclick="EditorTextFill(\';(\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/grin.gif" onclick="EditorTextFill(\':D\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/hmm.png" onclick="EditorTextFill(\':|\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/hypocrite.gif" onclick="EditorTextFill(\'0=)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/lock.gif" onclick="EditorTextFill(\':x:\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/love.gif" onclick="EditorTextFill(\':3\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/sunglasses.gif" onclick="EditorTextFill(\'8)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/shifty.gif" onclick="EditorTextFill(\'|)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\'O_o\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\':o\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/sweatingbullets.gif" onclick="EditorTextFill(\'^_^\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':p\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':P\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/wink.gif" onclick="EditorTextFill(\';)\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xo\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'XD\');" class="point" alt="smiley"> \
                <img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xD\');" class="point" alt="smiley">';
    }
    else
    {
        init = '<img src="data/img/buttons/bold.png" onclick="EditorTextFill(\'[b][/b]\');" class="point" alt="bold"> \
                <img src="data/img/buttons/italic.png" onclick="EditorTextFill(\'[i][/i]\');" class="point" alt="italic"> \
                <img src="data/img/buttons/underline.png" onclick="EditorTextFill(\'[u][/u]\');" class="point" alt="underline"> \
                <img src="data/img/buttons/strike.png" onclick="EditorTextFill(\'[s][/s]\');" class="point" alt="strike"> \
                <img src="data/img/buttons/link.png" onclick="EditorTextFill(\'[url][/url]\');" class="point" alt="Link"> \
                <img src="data/img/buttons/image.png" onclick="EditorTextFill(\'[img][/img]\');" class="point" alt="Image">';
    }

    init = '<img src="data/img/buttons/remove.png" alt="remove" class="closebutton point" onclick="EditorDivClose(\'edit-content\');">'+ init;

    $('#'+b).html(init);
}

function EditorTextFill(msg){
    $('#editor-textarea').html() = $('#editor-t开发者_如何学编程extarea').html() + msg;
}

            <img src="data/img/smileys/happy.gif" alt="smileys" onclick="EditorDivOpen('edit-content'); EditorDivFill('smileys', 'edit-content');" class="point">
            <img src="data/img/buttons/bold.png" alt="tags" onclick="EditorDivOpen('edit-content'); EditorDivFill('tags', 'edit-content');" class="point">
            <div id="edit-content">
            </div>

            <textarea cols="60" rows="6" name="message" id="editor-textarea"></textarea><br>
            <input type="submit" value="  submit  ">

Some of my functions on the code above won't work, those are EditorDivClose() and EditorTextFill(). At both I get the error:

this property or method is not supported by this object

by both at the first $ character.


There is no jQuery method called close. You need hide

function EditorDivClose(a){
    $('#'+a).hide();
}

To set the html value, you pass the value you want to set to the html method, like so

function EditorTextFill(msg){
    var oldVal = $('#editor-textarea').html();
    $('#editor-textarea').html(oldVal + msg);
}

or

function EditorTextFill(msg){
    $('#editor-textarea').html(function (i, oldVal) {
        return oldVal + msg
    });
}

Read some documentation at the jQuery documentation website or at jqapi.com. It helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜