首页 > 解决方案 > 如何使用 JS/JQ/ 从 Marquee 获取值以显示在标签中

问题描述

    <marquee id="marquee_element" class="marquee_element">
        <span class="notification_marquee first ">{{$announcement->announcement1}}</span>
        <span class="notification_marquee second not_sec">{{$announcement->announcement2}}</span>
        <span class="notification_marquee third not_3rd">{{$announcement->announcement3}}</span>
        <span class="notification_marquee fourth not_4th">{{$announcement->announcement4}}</span>
        <span class="notification_marquee fifth not_5th">{{$announcement->announcement5}}</span>
     </marquee>

我想打印在屏幕上的选框值,我还必须在标签上打印

  <span id="an_label_1" class="an_label not_fst"></span>
      

标签: javascriptjquerylaravel-5

解决方案


嗨,您可以使用此代码,如果您遇到任何问题,请告诉我

var label = $('#marquee1');

console.log(label.text());

$('#an_label_1').text(label.text());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<marquee id="marquee_element" class="marquee_element">
        <span class="notification_marquee first " id="marquee1">{{$announcement->announcement1}}</span>
        <span class="notification_marquee second not_sec">{{$announcement->announcement2}}</span>
        <span class="notification_marquee third not_3rd">{{$announcement->announcement3}}</span>
        <span class="notification_marquee fourth not_4th">{{$announcement->announcement4}}</span>
        <span class="notification_marquee fifth not_5th">{{$announcement->announcement5}}</span>
     </marquee>
     
      <span id="an_label_1" class="an_label not_fst"></span>


推荐阅读