如何将数据div传输到输入

时间:2017-09-28 18:28:17

标签: html input

我想将数据从div传输到隐藏输入

    // Set the directive
    angular
        .module('custom.directives')
        .directive('customvideo', customvideoDirective);

    // Set the directive $injections
    customvideoDirective.$inject = ['$Scope'];


 function customvideoDirective($Scope)  
{
            return {
                compile: compile,
                restrict: 'A',
                $Scope: {
                    isvalid: '=?'
                }
            };

  function compile() {
      console.log($Scope.isvalid);  //this is undefined 
     }
  }

})();

我的解决,但它不起作用:



<div id="timing"><table>...i need date from here...</table></div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

在这里,从html(...)更改为val(...)和html()更改为text():)

<script>
   $(document).ready(function(){
   $('#textarea').keyup(function() {
       $('#dateD').val($('#div.timing').text());
   });
});
</script>

<input type="hidden" id="dateD" value="" name="time1">

答案 1 :(得分:0)

$('#timing').text()允许您这样做。