简体   繁体   English

制作没有href的过渡文字

[英]Make a transition text without href

I have a div containing a group of divs. 我有一个包含一组div的div。

I want the divs inside to work as links that move to another page after saving this link's value. 我希望里面的div用作保存此链接的值后移至另一页的链接。

The div consists of the id in the div attribute, & the name in the div's value as follows: div由div属性中的id和div值中的名称组成,如下所示:

Html: HTML:

    <div id="ClasssesList" ></div> 

jQuery: jQuery的:

function GetClassesList(data) {
   var classes = (typeof data) == 'string' ? eval('(' + data + ')') : data;
   $('#ClasssesList').empty();
   for (var i = 0; i < classes.length; i++) {
      var text = '<button class="BigDiv" value="' + classes[i].Cls_ID + '" >' + classes[i].Cls_Name + '</button>';
    $('#ClasssesList').append(text);
   }
}

I want to save the value of the clicked id in a localStorage then move to the next page: 我想将单击的id的值保存在localStorage然后移至下一页:

I tried to make it as follows, but it doesn't seem to be working: 我试图使其如下,但似乎无法正常工作:

$("#ClasssesList").bind('click', 'button.BigDiv',CallLink()); 

function CallLink(e) {

        localStorage['ClassID'] = $('Button.BigDiv').attr('value');
        window.location.replace("Teacher_Attendance.htm");
 }

Do you know what should I do to let it work ? 您知道我该怎么做才能使其正常工作吗?

function CallLink(e) {

        localStorage.setItem('ClassID', $('Button.BigDiv').attr('value'));

        window.location.replace("Teacher_Attendance.htm");
 }

And to get that item try: 并获得该项目尝试:

localStorage.getItem('classID');

Format to set data to localStorage is 将数据设置为localStorage的格式为

localStorage.setItem(key, value);

here value is string format; 这里的valuestring格式;

you will get more here Microsoft , Mozilla and Apple . 您将在这里获得更多的MicrosoftMozillaApple

And one note 还有一个音符

I think your bind function 我认为你的绑定功能

$("#ClasssesList").bind('click', 'button.BigDiv',CallLink())

should be written as 应该写成

$("#ClasssesList").on('click', 'button.BigDiv',CallLink())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM