Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shopping_list
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
experiment_web_app
shopping_list
Commits
8d7fc0a2
Commit
8d7fc0a2
authored
Dec 18, 2017
by
jonathan Courat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add qty with plus button and increment function
#3
parent
d1235200
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
4 deletions
+44
-4
style.css
css/style.css
+22
-2
index.html
index.html
+9
-1
script.js
js/script.js
+13
-1
No files found.
css/style.css
View file @
8d7fc0a2
...
...
@@ -9,12 +9,32 @@
color
:
grey
;
}
.checkForPrint
{
.quantity
{
display
:
inline-flex
;
}
.plusBt
{
background-color
:
#4CAF50
;
/* Green */
border
:
none
;
color
:
white
;
padding
:
2px
8px
;
text-align
:
center
;
text-decoration
:
none
;
display
:
inline-block
;
font-size
:
18px
;
margin
:
4px
;
cursor
:
pointer
;
}
.checkForPrint
{
display
:
inline-flex
;
width
:
10px
;
height
:
10px
;
border-style
:
solid
;
}
}
/* @media section */
@media
print
{
.noprint
{
display
:
none
;
}
input
{
display
:
none
;
}
}
...
...
index.html
View file @
8d7fc0a2
...
...
@@ -15,11 +15,15 @@
<input
type=
"checkbox"
id=
"item_1"
name=
"cat1"
value=
"item 1"
>
<div
class=
"checkForPrint"
></div>
<label
for=
"cat1"
>
Pain
</label>
<p
class=
"quantity"
>
1
</p>
<button
class=
"plusBt"
>
+
</button>
</div>
<div
class=
"itemToSelect noprint"
>
<input
type=
"checkbox"
id=
"item_2"
name=
"cat_1"
value=
"item 2"
>
<div
class=
"checkForPrint"
></div>
<label
for=
"cat_1"
>
beurre
</label>
<p
class=
"quantity"
>
1
</p>
<button
class=
"plusBt"
>
+
</button>
</div>
</fieldset>
...
...
@@ -31,11 +35,15 @@
<input
type=
"checkbox"
id=
"item_3"
name=
"cat_2"
value=
"item 1"
>
<div
class=
"checkForPrint"
></div>
<label
for=
"cat_2"
>
fromage rapé
</label>
<p
class=
"quantity"
>
1
</p>
<button
class=
"plusBt"
>
+
</button>
</div>
<div
class=
"itemToSelect noprint"
>
<input
type=
"checkbox"
id=
"item_4"
name=
"cat_2"
value=
"item 2"
>
<div
class=
"checkForPrint"
></div>
<label
for=
"cat_2"
>
Yahourt
</label>
<label
for=
"cat_2"
>
Yahourt
</label>
<p
class=
"quantity"
>
1
</p>
<button
class=
"plusBt"
>
+
</button>
</div>
</fieldset>
</body>
...
...
js/script.js
View file @
8d7fc0a2
...
...
@@ -36,4 +36,16 @@ function displayItem() {
}
addEventListenerList
(
items
,
'click'
,
displayItem
);
\ No newline at end of file
addEventListenerList
(
items
,
'click'
,
displayItem
);
//plusBt[0].previousElementSibling.innerHTML = Number(plusBt[0].previousElementSibling.innerHTML) + 1;
let
plusBt
=
document
.
querySelectorAll
(
'.plusBt'
);
function
incrementQuantity
()
{
console
.
log
(
this
);
this
.
previousElementSibling
.
innerHTML
=
Number
(
this
.
previousElementSibling
.
innerHTML
)
+
1
;
}
addEventListenerList
(
plusBt
,
'click'
,
incrementQuantity
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment