English 中文(简体)
在纽特州点击甚至代码(行为问题)的旋转案文
原标题:rotate text at button click even code (having issue)
<style type="text/css" media="screen">
.square {
    width: 144px;
    height: 144px;
    background: #fff;
    margin-right: 48px;
    float: left;
}

.transformed {
    -webkit-transform: rotate(15deg) scale(1.25, 0.5);
    -moz-transform: rotate(15deg) scale(1.25, 0.5);
    transform: rotate(15deg) scale(1.25, 0.5);
}
</style>
<script type="text/javascript">

function change(txt){
    var d = document.getElementById( derg ).value;alert(d);
    //alert(txt);
    //alert(d);
    //var a1=5;
    //var a2=5;
    //var a3=a1+a2;
    //alert(a3);

    var dd = d+txt;
    alert(dd);
    document.getElementById( derg ).value=dd;
    var a=dd+ deg ;
    //alert(a);

    document.getElementById( tdiv4 ).style.MozTransform =  rotate( +a+ ) ;
}
</script>



<div id="tdiv4" class="square" >this is tdiv4</div>

<input type="hidden" value="" id="derg">
<input type="button" onclick="change(20)" value="change"/>

轮换是完美无缺的,但问题是,它没有在新价值中增加以前的价值,而新价值是混杂的。 假设原值20和新的价值2o,则轮值应为40代。 但它显示,2020年是这一问题的轮值。 请让我帮助我。

最佳回答

JSFiddle

function change(txt){
    var d = document.getElementById( derg ).value || 0;

    var dd = parseInt(d)+parseInt(txt);

    document.getElementById( derg ).value=dd;
    var a=dd+ deg ;


    document.getElementById( tdiv4 ).style.MozTransform =  rotate( +a+ ) ;
}

它确实需要教区。 但也需要具有初步价值,例如,如果它没有价值,它就需要0。

问题回答

You need to convert your d and txt values from strings to numbers. e.g.

var number = parseInt(d);

你们首先可以测试Nan的错误,例如Nan。

if (!isNaN(d)) {
   var number = parseInt(d);
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签