0
클릭하면 jQuery를 사용하여 열리는 주석 영역 위에 스마일 아이콘이있는 상자를 추가하고 싶습니다. 내가 마련하는 것은 이것이다 :html로 스마일 박스를 만드는 가장 좋은 방법
<div class="emo">
<i href="#" id="showhide_emobox"> </i>
<div id="emobox">
<input class="emoticon" id="icon-smile" type="button" value=":)" />
<input class="emoticon" id="icon-sad" type="button" value=":(" />
<input class="emoticon" id="icon-widesmile" type="button" value=":D" /> <br>
</div>
</div>
CSS :
.emoticon-smile{
background: url('../smileys/smile.png');
}
#icon-smile {
border: none;
background: url('../images/smile.gif') no-repeat;
}
jQuery를 :
// =======show hide emoticon div============
$('#showhide_emobox').click(function(){
$('#emobox').toggle();
$(this).toggleClass('active');
});
// ============add emoticons============
$('.emoticon').click(function() {
var textarea_val = jQuery.trim($('.user-comment').val());
var emotion_val = $(this).attr('value');
if (textarea_val =='') {
var sp = '';
} else {
var sp = ' ';
}
$('.user-comment').focus().val(textarea_val + sp + emotion_val + sp);
});
나는 어려움 좋은 배열에 버튼을 배치 있고 (그들을 위해 배경 이미지를 만들 그러나 버튼 값이 이미지 앞에 나타나고 배열이 완벽하게 사각형이 아니므로이 상자를 렌더링하는 가장 좋은 방법이 아닌 것인지 궁금합니다.
제대로 할 수있는 아이디어가 있습니까?
당신이 버튼의 값을해야합니까 : 입력 요소에 대한 필요가 돔 노드의이 같은
뭔가를 텍스트를 얻을 수 없습니다? 당신이 이미지를 표시하려고한다면 과잉 보인다. – daker
@daker, yes, 값은 jQuery (코드가 추가됨)에 의해 그레이 빙되어야합니다. – Jand
모든 ' '은 무엇입니까? –