drnzpd579935 2016-04-25 15:49
浏览 22
已采纳

在UI小部件中集成文本和图像

hello I would like to know how I can add text and image inside a UI widget I also want it to be without a background please help I want to be able to write my own text and display while I'm writing it.

CSS

.thumbs img{
 margin:3px;
width:50px;
float:left;
}
.bottlesWrapper img{
margin:3px;
width:400px;
float:left;
}

#main { border:1px solid #eee; margin:20px; width:410px; height:220px;}

HTML

 <html>
 <head>
 <script  
 src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <meta charset=utf-8 />
 <title>UI widget</title><link rel="stylesheet"
href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  <link rel="stylesheet"
 href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<link rel="stylesheet" href="/resources/demos/style.css">
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">

<textarea rows="5" cols="20" name="quote" wrap="physical">Enter your favorite quote!</textarea><br />

<input type="submit" value="submit" name="submit">
</form>
<div id='main'>
<div class="bottlesWrapper">

 <div id="dialog" class="ui-widget-content"> 
     <?


  echo "<i>".$quote."</i><br />";


   ?> 
    </div>

 <img src="http://placehold.it/300x160/f1f" />
 </div>

  <div class="thumbs">
 <img src="http://placehold.it/300x180/444" />
 <img src="http://placehold.it/300x160/f1f" />


  </div></div>

  </body>
  </html>

Script

$('.thumbs img').click(function() {
var thmb = this;
var src  = this.src;
$(thmb).parent('.thumbs').prev('.bottlesWrapper').find('img').fadeout (400,function(){
    thmb.src = this.src;
    $(this).fadeIn(400)[0].src = src;
   });
   });

   </script>  <script>
   $("#dialog").dialog({
   open: function(event, ui) {
    var vDlg = $(event.target).parent();
    var vCont = $('#main');
    vDlg.draggable("option", "containment", vCont).appendTo(vCont);
    $(this).dialog("option", "position", "center");
     }
   });

https://jsfiddle.net/barronfidel7/c1yfj0wv/

  • 写回答

1条回答 默认 最新

  • doudou_3636 2016-04-25 16:39
    关注

    Your working fiddle.

    This is what allows you to see the HTML in the UI widget as you type:

    $(document).ready(function(){
      $('#dialog').html($('#quote').val());
      $('#quote').on('keyup', function(){
        $('#dialog').html($(this).val());
      });
    });
    

    While the input has focus, it assigns the HTML of the widget to it's own value after every keyup event.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!